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

what's the disadvantage of namedChunks? #8354

Closed
Justin-Shen opened this issue Nov 8, 2018 · 11 comments
Closed

what's the disadvantage of namedChunks? #8354

Justin-Shen opened this issue Nov 8, 2018 · 11 comments
Labels

Comments

@Justin-Shen
Copy link

Justin-Shen commented Nov 8, 2018

In production mode, namedChunks is default to false, so what is the disadvantage of namedChunks, I think it is necessary in production.

webpack version: 4.25.1

e.g.

before

  • I have 3 entries: entry-a & entry-b & entry-c

image

then

  • Add a new entry: aa

image

  • as chunk name is ids in production, after I added this new entry, entry-a / entry-b / entry-c‘s chunkhash is also changed. because all this entries' chunk name is changed, from 1 to 2, from 2 to 3....

image

image


The outcome was undesired !

I think when I add a new entry, all the existed entries' chunkhash will not be changed. Or the cache will be failed, even though their contents have not changed.

To resolve this problem is add optimization.namedChunks: true in production mode.

image

But why it is default to false? Is that any problem?

And it will be removed in webpack 5 ?
image

@ooflorent
Copy link
Member

And it will be removed in webpack 5?

namedChunks will be removed because it is redundant with chunkIds. Here is a simplified representation of how chunkIds works:

optimization.chunkIds = optimization.namedChunks ? "named" : 

@Justin-Shen
Copy link
Author

And it will be removed in webpack 5?

namedChunks will be removed because it is redundant with chunkIds. Here is a simplified representation of how chunkIds works:

optimization.chunkIds = optimization.namedChunks ? "named" : 

Thanks! How to set the chunkId in webpack 4 ? Use the hook optimizeChunkIds ?

@ooflorent
Copy link
Member

How to set the chunkId in webpack 4 ? Use the hook optimizeChunkIds ?

Unfortunately it is not possible in v4.
This option has landed on next branch (v5).

@smelukov
Copy link
Member

smelukov commented Nov 8, 2018

This option has landed on next branch (v5).

@ooflorent can you get a link to the source, please?
Want to get more info :)

@smelukov
Copy link
Member

smelukov commented Nov 8, 2018

@ooflorent thank you!
What do you think about #8355 ?

@sokra
Copy link
Member

sokra commented Nov 11, 2018

chunkIds: "named" is also available in webpack 4.

"chunkIds": {
"description": "Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)",
"enum": ["natural", "named", "size", "total-size", false]
},

@sokra
Copy link
Member

sokra commented Nov 11, 2018

There are disadvantages:

  • bundle size increases a bit (you probably don't care about a few bytes)
  • chunk name (in webpack 5 also module name) information leak into public (not sure if you care)

@sokra
Copy link
Member

sokra commented Nov 11, 2018

The advantage of better long term caching will also provided by deterministic chunk ids like @smelukov mentioned.

@webpack-bot
Copy link
Contributor

This issue had no activity for at least half a year.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@alexander-akait
Copy link
Member

Answer above, feel free to feedback

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

6 participants