codesandbox-client icon indicating copy to clipboard operation
codesandbox-client copied to clipboard

When package name in dependencies and `npm:` specifier differ, Codesandbox fails to load correct URL from CDN

Open steveluscher opened this issue 1 year ago • 2 comments

🐛 bug report

Preflight Checklist

  • [x] I have read the [Contributing Guidelines][contributing] for this project.
  • [x] I agree to follow the [Code of Conduct][code_of_conduct] that this project adheres to.
  • [x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Description of the problem

Consider these dependencies in package.json:

"dependencies": {
  "@solana/web3.js": "^2.0.0-preview",
  "@solana/web3.js-legacy": "npm:@solana/web3.js@^1"
}

This results in this console error:

Error: Could not fetch https://cdn.jsdelivr.net/npm/@solana/web3.js@^1-legacy/lib/index.browser.esm.js
Error: Could not fetch https://unpkg.com/@solana/web3.js@^1-legacy/lib/index.browser.esm.js

Essentially something is mangling the package name, taking the -legacy string in the alias and tacking it onto the CDN URL when it should be left out.

How has this issue affected you? What are you trying to accomplish?

The modules don't load and the sandbox is unusable.

To Reproduce

Run this sandbox.

Link to sandbox: link

steveluscher avatar May 24 '24 18:05 steveluscher

I hit this again today. Is this easy to fix?

steveluscher avatar Jun 20 '24 19:06 steveluscher

Hi @steveluscher. Thanks for reporting this. I've forwarded it to our Engineering team and they will investigate. We will keep you posted on a fix.

filipelima18 avatar Jul 10 '24 16:07 filipelima18

@filipelima18 any news on this one? I am hitting this lately too

Image

Related to dependencies here https://github.com/plotly/plotly.js/blob/master/package.json#L110

stevelewis99 avatar Jan 22 '25 20:01 stevelewis99

Found the issue and opened a PR with a fix. It looks like our Nodebox (in-browser Node.js runtime) did not understand npm aliases if the npm alias referred to a scoped package.

CompuIves avatar Jan 23 '25 11:01 CompuIves

Heya! Just published the fix. You should not have the issue anymore!

CompuIves avatar Jan 23 '25 11:01 CompuIves

@CompuIves thank you so much, confirming that this issue is now fixed for me!

stevelewis99 avatar Jan 29 '25 10:01 stevelewis99