-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Add support for webpack's CommonsChunkPlugin #301
Conversation
This example features: | ||
|
||
* An app with two pages which has a common Counter component | ||
* That Counter component maintain the counter inside it's module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe reword this sentence? It's not 100% clear to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe say something along the lines: the common plugin maintains state that is initialized only once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking great!!!
👍 |
Superb! |
Does this mean no configuration is required to make a component/module "common"? |
@jonaswindey no we don't need. Currently it uses defaults options for commonChunksPlugin In a future(near) version of Next.js we'll offer some ways to configure options for |
@jonaswindey more info about the current logic of common modules. If a module used in all of the pages, it will move into the commons JavaScript bundle. But in anyway, a module only loads once even if pages contains multiple copies of it. |
One thing to consider is how aggressively assets are concatenated in http2 setups:
|
Fixes #253
Similar to #286 (We didn't take #286 in)
Here now common modules loads once using the webpack's CommonsChunkPlugin. Still, we use Next.js module loading system and SSR features.
As a result of this, we don't need to worry about loading the next-bundle and even creating it.