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 month ago • 1 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