Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React 19] : npm install react -- missing umd module #31867

Open
Faim00 opened this issue Dec 20, 2024 · 4 comments
Open

[React 19] : npm install react -- missing umd module #31867

Faim00 opened this issue Dec 20, 2024 · 4 comments
Labels

Comments

@Faim00
Copy link

Faim00 commented Dec 20, 2024

UMD folder missing in React 19+ installation via npm

After installing React version 19.x.x using npm, the umd folder (which typically contains files like react.development.js and react.production.min.js) is missing from node_modules/react. These files are essential for UMD builds and are expected to be included in the package as per React's documentation. The same issue is observed for react-dom.

@Faim00 Faim00 changed the title [React 19] : npm install react [React 19] : npm install react -- missing umd module Dec 20, 2024
@adi-ydv-1
Copy link

If you need to use React in a UMD-compatible environment, you can consider using an older version of React that still includes the umd folder. Alternatively, you can explore other options, such as using a bundler like Webpack or Rollup to create a UMD-compatible bundle @Faim00

@magicdawn
Copy link

https://unpkg.com/react-umd/dist/react.umd.js
https://unpkg.com/react-umd/dist/react-dom.umd.js
https://unpkg.com/react-umd/dist/react-dom-client.umd.js


I'm building this with rspack

But still a feature request for adding official UMD build back, since if react not providing UMD build, UI libraries will follow not providing UMD build. (e.g mui)

@guillaumebrunerie
Copy link

@lofcz
Copy link

lofcz commented Jan 4, 2025

https://unpkg.com/react-umd/dist/react.umd.js https://unpkg.com/react-umd/dist/react-dom.umd.js https://unpkg.com/react-umd/dist/react-dom-client.umd.js

I'm building this with rspack

But still a feature request for adding official UMD build back, since if react not providing UMD build, UI libraries will follow not providing UMD build. (e.g mui)

The issue with this is ReactDomClient exporting ReactDOMClient into window, instead of its properties being available on ReactDOM, for example ReactDOM.createRoot(). I've written a monkey patch for restoring the behavior but it's a pretty ugly solution (although it works). Also, this produces binaries about 365Kb in size instead of the 200Kb I'd expect.

Edit: with some more tinkering I've reduced the built size to the expected 180Kb for both React and ReactDOM summed up. Updated script: https://gist.github.com/lofcz/85de631f88d9b6c49fdc2f4bde184193

This can be built by installing the dependencies and then rollup -c rollup.config.react.js
Built files: react19.production.min.js react-dom19.production.min.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants