esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

Proposal: pin react and react-dom

Open nihgwu opened this issue 3 years ago • 10 comments

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

nihgwu avatar Mar 20 '22 17:03 nihgwu

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

nihgwu avatar Mar 20 '22 19:03 nihgwu

yes, this makes a lot of sense, but need to be very careful, how to ensure the 'stable' is actual stable

ije avatar Mar 21 '22 01:03 ije

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 alias react to remote version, I'll switch to classic runtime

i will improve it

ije avatar Mar 21 '22 01:03 ije

https://github.com/esm-dev/esm.sh/commit/f2cfe998dd01fbf743a0b16925398e7b8b10f31f now support jsx-runtime with query:

Screen Shot 2022-03-21 at 12 00 59

ije avatar Mar 21 '22 04:03 ije

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

nihgwu avatar Mar 21 '22 08:03 nihgwu

@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

nihgwu avatar Mar 30 '22 13:03 nihgwu

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 avatar Mar 30 '22 14:03 ije

@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

nihgwu avatar Mar 30 '22 14:03 nihgwu

i will look into it!

ije avatar Mar 30 '22 18:03 ije

@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 image

nihgwu avatar Apr 07 '22 21:04 nihgwu

i believe this has been done

ije avatar Mar 23 '23 12:03 ije