question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Next 9] Importing react-dom would bloat the bundle size

See original GitHub issue

Bug 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 imports react-dom

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to ‘pages/any-page.js’
  2. Add import ReactDOM from 'react-dom';
  3. In the render function, do console.log(ReactDOM). Just to use that dependency.
  4. 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
timneutkenscommented, Aug 26, 2019

@zenozen it’s fixed in the new chunking behavior:

module.exports = {
  experimental: {
    granularChunks: true
  }
}
0reactions
balazsorban44commented, Jan 31, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found