Visiting https://unpkg.com/react displays the CJS build (https://unpkg.com/[email protected]/index.js) when the UMD build (https://unpkg.com/[email protected]/umd/react.development.js) should be displayed instead. I also noticed this issue with react-dom, so I assume all packages need to be fixed.
Please refer to the usage instructions at the bottom of https://unpkg.com/.
Please see the discussion in https://github.com/facebook/react/pull/10597. It’s intentional.
👎 This is anti-beginner in my opinion. It is standard for Unpkg URLs to point to development builds, and we are breaking user expectations. It's much worse for the default URL to literally error because browsers do not support common JS than to serve a development build, which will be displayed in the React Devtools extension anyway.
By the way, if the concern is about the user not knowing the development build is provided by default (which they would probably already know by using other Unpkg packages), Unpkg redirects the user to the full UMD file path, making the path that is used by default clear.
For example, https://unpkg.com/jquery redirects to https://unpkg.com/[email protected]/dist/jquery.js, which is clearly unminified and build for development.
This is anti-beginner in my opinion.
We've been there before. If React doesn't make this choice then it's "anti-beginner". If React does, then it'll be "anti-performance". Either way somebody will be unhappy. See discussion in https://github.com/facebook/react/issues/8784. We have to educate developers about the differences between builds, and the only way to do so is to force them to choose one or the other. I think that if you can drop a script tag on the page without thinking about whether it should be a dev or a prod build, we're going to keep seeing sites ship development versions to production, and hurting the user experience.
Unpkg redirects the user to the full UMD file path, making the path that is used by default clear.
Only if you read the redirect result URL.
It is standard for Unpkg URLs to point to development builds, and we are breaking user expectations.
What do you mean by "standard"? Do all libraries do that? For libraries that do, are their DEV builds several times larger and smaller, like React DEV build is?
It's much worse for the default URL to literally error because browsers do not support common JS than to serve a development build
I agree! I don't know why unpkg attempts to serve a CommonJS entry point (which main stands for). Instead it would be great if it served some page that suggested to find the proper UMD build inside.
Unpkg could provide first-class support for multiple explicitly chosen UMD versions.
For example:
https://unpkg.com/react:development
https://unpkg.com/react:production
https://unpkg.com/react-dom:development
https://unpkg.com/react-dom:production
This works with versions too:
https://unpkg.com/react-dom:[email protected]
Since : is reserved, it won't cause clashes.
This could work by special fields in package.json, e.g.
"umd:development": "umd/react.development.js",
"umd:production": "umd/react.production.js"
For packages that opted into this, unpkg could display a better error page when you attempt to load https://unpkg.com/react directly — and show disambiguating links right there. Seems like best of both worlds to me.
If unpkg is interested in implementing the above, we could do it.
I still disagree with not using umd/react.development.js as a stopgap solution, but I like your suggestion as Unpkg does not have a way to choose alternative entry points without knowing the full file path. Maybe it could even 404 to make it very obvious that a package doesn't have a default entry point for both development and production. I'll cross-post an issue.
react@16 is redirecting to 16.6.2 which doesn't seem to exist, and when you go to the CJS version, it says it is version 16.6.1 - which does work on UMD
please excuse me if I don't understand something properly, I am new to using unpkg as per instructions from React documentation

Sorry for commenting here, I meant to put it in a closed issue on unpkg https://github.com/unpkg/unpkg.com/issues/38 if folks wouldn't mind letting it stay here for their reference? Otherwise I can delete and move it too. However, FWIW I was following directions here https://reactjs.org/docs/add-react-to-a-website.html
There was a broken release. It's fixed now.
Thank you for the update, and so quickly! I really appreciate that. Cheers
Depends on https://github.com/mjackson/unpkg/issues/93
Most helpful comment
Please see the discussion in https://github.com/facebook/react/pull/10597. It’s intentional.