sandpack-bundler
sandpack-bundler copied to clipboard
Failing to install npm dependencies when using self-hosted bundlerURL
Bug report
Packages affected
- [ ] sandpack-client
- [x] sandpack-react
Description of the problem
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)
Link to sandbox: link
Your Environment
Software | Name/Version |
---|---|
Sandpack-client version | |
Sandpack-react version | 1.0.0 and also tried 1.8.8 |
Browser | Chrome |
Operating System | MacOS |
@DeMoorJasper could you please take a look at this issue?
Any updates on this? I tried it on another PC and still get the same errors. It's a bit odd since some libraries work with the locally hosted bundler whereas others don't.
And all libraries work fine when using the CDN bundler. So it's almost like the locally hosted bundler is not the same as the CDN one.
Is there another bundler that can be used in the same way and is compatible with Sandpack?
It should be identical to using: https://sandpack-bundler.pages.dev/
as bundlerUrl. You're probably comparing it to the v1 bundler which is still the default for sandpack, for which the sourcecode is here: https://github.com/codesandbox/codesandbox-client
If I change the bundlerUrl from my locally hosted bundler (https://github.com/codesandbox/sandpack-bundler), to https://sandpack-bundler.pages.dev/
I still get the same error. The only thing that works is not defining bundlerUrl so that it uses the default CDN bundler (which I don't want to use.)

Yes, that's what I suspected, it's a bug in the new v2 bundler, you should probably follow this guide instead for self-hosting the v1 bundler: https://sandpack.codesandbox.io/docs/advanced-usage/client#hosting-the-bundler
How do I host the www
file? I'm trying just npx http-server
and then passing http://127.0.0.1:8080/
as the bundlerUrl
but that doesn't seem to work.
Ideally I'm looking to only host the bundler. Is the bug with sandpack-bundler
being tracked?
Thanks.
Hey @DeMoorJasper, is this still an issue? I assume it is fixed by now.
Don't think we've fixed this on the new experimental bundler, but it works on the stable bundler.
We're not yet sure how we're gonna fix this yet.