codesandbox / sandpack-bundler Goto Github PK
View Code? Open in Web Editor NEWThe new bundler/runtime powering client-side sandpack sandboxes
Home Page: https://sandpack-bundler.codesandbox.io
License: Apache License 2.0
The new bundler/runtime powering client-side sandpack sandboxes
Home Page: https://sandpack-bundler.codesandbox.io
License: Apache License 2.0
I have this sandpack-bundler running: https://github.com/codesandbox/sandpack-bundler
In the example sandbox below, you will see I am setting the bundlerURL in the SandboxProvider.
The sandpack created doesn't actually work though due to failing to properly important the library. It works fine when I don't set bundlerURL and use the default bundler. Example of the error:
(Sometimes the error is about failing to import other stuff like Cannot find module 'process' from '/node_modules/vfile/lib/minproc.js'
)
It works fine when I try other libraries like "uuid: latest", but testing with "react-markdown: latest" has given me these errors. I've tried a couple other libraries and had issues with them too. It's like it's not doing npm install
properly.
Again I should note that if I don't define bundlerURL and use the default, it works fine.
(Side note: sandpack-client and sandpack-react seem to use a different bundler version, 1.7.0 vs 1.8.8)
Software | Name/Version |
---|---|
Sandpack-client version | |
Sandpack-react version | 1.0.0 and also tried 1.8.8 |
Browser | Chrome |
Operating System | MacOS |
README.md
has a link to https://www.figma.com/file/I2Gm2pGCRdWMoBWxXrvYib/sandpack-bundler-architecture?node-id=0%3A1 but following the link (and logging into figma) leads me to a page with the following error message
File not found
Either this file doesn’t exist or you don’t have permission to view it. Ask the file owner to verify the link and/or update permissions.
Currently, the v1 returns the bundler-state to Sandpack, which contains a lot of useful information. For example, the compiled files are mandatory information to render SandpackTranspiledCode
.
V1: https://github.com/codesandbox/codesandbox-client/blob/master/packages/app/src/sandbox/compile.ts#L873-L876
Sandpack: https://github.com/codesandbox/sandpack/blob/main/sandpack-client/src/client.ts#L214-L217
If you point me out the right place, I can try to implement it
The bundled HTML doesn't have a doctype, meaning browsers choose quirks mode for the Sandpack previews. I noticed this on https://react.dev, which has many previews.
An easy way to reproduce is to check https://react.dev/learn
It looks like the bundler starts with its own index.html and uses src/utils/html/replaceHTML
to replace the body with the user's HTML body. Seems like the simplest fix is to add <!DOCTYPE html>
to the start of the bundler's index.html. I ran react.dev and sandpack-bundler locally and that got rid of quirks mode.
The current approach is a little confusing, though. The user's own index.html (which sometimes comes from Sandpack's templates) gets passed to the bundler and then ignored, which made for a surprising debugging experience. In the long term, it would be nice if the index.html supplied by the user had priority over the bundler's index.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.