You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/sandpack/README.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,6 +198,24 @@ The third argument in the constructor of `Manager` is extra options. It has this
198
198
}
199
199
```
200
200
201
+
## Why is the bundler hosted externally and not a simple `import`?
202
+
203
+
We have three reasons to host the bundler of sandpack externally:
204
+
205
+
### Security
206
+
207
+
The bundler evaluates and transpiles all files in an iframe under a different subdomain. This is important, because it prevents attackers from tampering with cookies of the host domain when evaluating code.
208
+
209
+
### Performance
210
+
211
+
We heavily make use of Web Workers for transpilations. Almost all our transpilation happens in web workers, and there is no easy way yet to bundle this in a library.
212
+
213
+
### Bundle Size
214
+
215
+
Another reason to host the bundler externally is because of code splitting: we split all our transpilers away and load them on-demand. If a user doesn't use `sass` we won't load the transpiler. This wouldn't be possible if we would give one big JS file as the library.
216
+
217
+
> I want to highlight that you can also host the bundler by yourself, all necessary files are in the `sandpack` folder.
218
+
201
219
## Open In CodeSandbox
202
220
203
-
We show a "Open in CodeSandbox" button in the sandbox preview on the bottom right. This button allows everyone to create a sandbox from the code in the preview, open it in CodeSandbox and share their work more easily with others.
221
+
We show an "Open in CodeSandbox" button in the sandbox preview on the bottom right. This button allows everyone to create a sandbox from the code in the preview, open it in CodeSandbox and share their work more easily with others.
0 commit comments