Start WebContainer
June 9, 2023 ยท View on GitHub
Start WebContainer, and use Jsh and Preview URL.
This extension dynamically generates an external tab with Cross Origin isolation enabled using Nodebox(the Server tab in the figure below). Therefore, the ?vscode-coi=on parameter is not required in VS Code for the Web.

โ ๏ธ VS Code Insiders
VS Code insides for the Web has Cross Origin isolation turned on by default.
https://code.visualstudio.com/blogs/2023/06/05/vscode-wasm-wasi#_vs-codes-wasi-implementation
The only difficulty with this approach is that
SharedArrayBufferandAtomicsrequire the site to be cross-origin isolated, which, because CORS is very viral, can be an endeavor by itself. This is why it is currently only enabled by default on the Insiders version insiders.vscode.dev and must be enabled using the query parameter?vscode-coi=onon vscode.dev.If you use Start WebContainer, you have to set
?vscode-coi=off.
Features
- Start WebContainer from VS Code for the Web
- Open a terminal with Jsh
- Open Preview URL with Simple Browser
- Automatically reflect changes to WebContainer when there are any changes to the Workspace file
- Import WebContainer files to Workspace
Background file sync is not supported. Does not supported to multi-root workspace. Containers are not persistent.
Usage
Start WebContainer(Open terminal with Jsh)
- Open the Workspace(Local folder or Remote repository)
- Execute the
Start WebContainer: Startcommand from the command palette - The URL(
https://*.nodebox.codesandbox.io/) for starting WebContainer will open in an external tab - Workspace files will be loaded to WebContainer
When you edit files in the editor, they will be automatically reflected in WebContainer. However, it will not be reflected in the following cases.
- Changes outside the editor
- Create and delete files
๐
npm install:
npm installis not executed automatically. Please execute it manually- Even if
package.jsonandpackage-lock.jsonare updated, they will not be automatically reflected in the Workspace(SeeStart WebContainer: Pick up all files from a containerbelow)
Open Preview URL
- Execute the
Start WebContainer: Previewcommand from the command palette - Select from the list of available Prview URLs
- The Preview URL will open in the Simple Browser
Pick up all files from a WebContainer
- Execute the
Start WebContainer: Pick up all files from a containercommand from the command palette - The files in the WebContainer will be overwritten to the Workspace