esm.sh
esm.sh copied to clipboard
Proposal: pin react and react-dom
esm.sh updates frequently and every time it will break my app and got this error, because of cache, some packages will resolve to old build, which will lead to multi versions of React, and that will break the rule of React Hooks, so to solve this problem I have to pin the version from my side, but I think the build for react is already super stable, can we just solve it to export * from "https://cdn.esm.sh/stable/[email protected]/es2021/react.js"; instead of export * from "https://cdn.esm.sh/v71/[email protected]/es2021/react.js";
Or we always point latest version as https://cdn.esm.sh/edge/module for all packages, if someone want to pin to a previous version, they will get https://cdn.esm.sh/vXX/module
A problem with pinning version is that I got this error Uncaught SyntaxError: The requested module 'https://esm.sh/react?pin=v71/jsx-runtime' does not provide an export named 'jsx' https://github.com/nihgwu/react-runner/pull/105, OK to be fair, it will only happen if I alias react to remote version, I'll switch to classic runtime
yes, this makes a lot of sense, but need to be very careful, how to ensure the 'stable' is actual stable
A problem with pinning version is that I got this error
Uncaught SyntaxError: The requested module 'https://esm.sh/react?pin=v71/jsx-runtime' does not provide an export named 'jsx'nihgwu/react-runner#105, OK to be fair, it will only happen if I aliasreactto remote version, I'll switch to classic runtime
i will improve it
https://github.com/esm-dev/esm.sh/commit/f2cfe998dd01fbf743a0b16925398e7b8b10f31f now support jsx-runtime with query:
yes, this makes a lot of sense, but need to be very careful, how to ensure the 'stable' is actual stable
So in the later example I changed to edge, so we always point to latest build
@ije I have new problem even I locked react version to 17.0.2, here is the demo
I guess it's some deep dependency is referring to a wild version, the 321 error is driving me crazy, I'm going to use servicer worker to proxy it to local version instead
since react upgrade to 18, i guess some libraries was built with the latest react version, you need add [email protected] when import those library
@ije that's what I did, you can check the outgoing requests, all appended with [email protected], so that's why I suspect the wild version is from a deep dependency
i will look into it!
@ije Now I've locked the react version via Service Worker, but now I got a new issue, esm.sh version mismatch, I've locked to v74, but seems internal packages got resolved to latest version

i believe this has been done