Skip to content

Commit 7e69556

Browse files
author
Ives van Hoorne
committed
Update README
1 parent dea8aba commit 7e69556

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/sandpack/README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,24 @@ The third argument in the constructor of `Manager` is extra options. It has this
198198
}
199199
```
200200

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+
201219
## Open In CodeSandbox
202220

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

Comments
 (0)