[Next 9] Importing react-dom would bloat the bundle size
See original GitHub issueBug report
Describe the bug
Importing react-dom in a page or in one of its dependent component will cause react-dom.production.min.js to be included in the page bundle, adding about 32K gzipped size to a page.
This is pretty common, examples:
- ReactDOM.createPortal
react-transition-group
also importsreact-dom
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Go to ‘pages/any-page.js’
- Add
import ReactDOM from 'react-dom';
- In the render function, do
console.log(ReactDOM)
. Just to use that dependency. - Production build the project and inspect the bundle size
Expected behavior
react-dom should just be in the common bundle, not included again here. This does not happen with Next 8.
Screenshots
System information
- OS: macOS
- Version of Next.js: 9.0.1
Additional context
Add any other context about the problem here.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:12 (5 by maintainers)
Top Results From Across the Web
[Next 9] Importing react-dom would bloat the bundle size #7949
Go to 'pages/any-page.js' · Add import ReactDOM from 'react-dom'; · In the render function, do console.log(ReactDOM) . Just to use that dependency ...
Read more >Slimming down your bundle size - LogRocket Blog
A critical part for improving frontend performance is to reduce the JavaScript bundle size that should be downloaded via the network.
Read more >I give up on trying to reduce our angular bundle size - Reddit
I found the worst bloat comes from scss imports. Have you checked that you're not bringing in any dependencies with your component imports?...
Read more >Reduce JS Bundle Size by Dynamically Importing es6 Modules
One way to reduce JavaScript bundle size is to dynamically import es6 modules which are not required for the initial loading of the...
Read more >React-DOM — importing only render yields same bundle size ...
Webpack has a recommended bundle size of 244kb, so simply using React-DOM takes up nearly half of that space. Why is this? And...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@zenozen it’s fixed in the new chunking behavior:
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.