You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently encountered a problem where I changed some imports in a split chunk, which caused the app chunk output to change without it's hash changing. Because the app chunk is cached, mayhem ensues due to webpack exports no longer being consistent between chunks.
I've found two workarounds:
removing webpack-md5hash from createWebpackConfig.js - this causes both the app and split chunks hash to change.
adding transform-es2015-modules-commonjs to the babel plugins config to counteract the modules: false config. This disables the tree-shaking and causes only the split chunk hash to change.
I'm using Workaround 2 as there's no external way to use Workaround 1. It disables tree-shaking, but I haven't seen much of a difference in chunk sizes to be honest - I'm not sure they've figured it out completely yet, for instance: webpack/webpack#2867. This also makes more sense that only the split chunk changes as that is where the original source was changed.
It would be nice to remove webpack-md5-hash even if via nwb.config.js somehow.
Thoughts?
The text was updated successfully, but these errors were encountered:
Thanks for the thorough investigation and the repro repo 👍
Will drop use of md5-hash in this case, as it looks like Webpack 2 now does what you'd expect with chunk hashes.
It also used to be the case that if you just changed some extracted CSS, the chunkhash of JS emitted from the same chunk would also change. I'm not seeing that any more and I can confirm Workaround 1 works for me as for you.
This issue is a:
I recently encountered a problem where I changed some imports in a split chunk, which caused the app chunk output to change without it's hash changing. Because the app chunk is cached, mayhem ensues due to webpack exports no longer being consistent between chunks.
I've found two workarounds:
webpack-md5hash
fromcreateWebpackConfig.js
- this causes both the app and split chunks hash to change.transform-es2015-modules-commonjs
to the babel plugins config to counteract themodules: false
config. This disables the tree-shaking and causes only the split chunk hash to change.I've set up a small test project that can reproduce the issue: https://github.com/grahamlyus/nwb-chunkhash-issue
Default nwb settings
split.js:
yarn build
:Changing the import in split.js:
yarn build
:diff of
app.f709a8e5.js
c changes from 2 to 3 which won't be picked up as the script will be cached as the filename has not changed:diff of split chunk only the chunk hash has changed:
Workaround 1 - webpack-md5hash removed from (createWebpackConfig) config
import { CONSTANT_2 } from './constants.js'
:import { CONSTANT_3 } from './constants.js'
:diff of app chunks (hash has changed):
The split chunk is identical, and that is ok, as the reference
c
now points to the other import.Workaround 2 - babel plugin transform-es2015-modules-commonjs in nwb.config.js
import { CONSTANT_2 } from './constants.js'
:import { CONSTANT_3 } from './constants.js'
:app chunk is identical
split chunk diff correctly uses
CONSTANT_3
:There are a couple of issues on the https://github.com/erm0l0v/webpack-md5-hash/issues repo alluding to similar problems.
I'm using Workaround 2 as there's no external way to use Workaround 1. It disables tree-shaking, but I haven't seen much of a difference in chunk sizes to be honest - I'm not sure they've figured it out completely yet, for instance: webpack/webpack#2867. This also makes more sense that only the split chunk changes as that is where the original source was changed.
It would be nice to remove webpack-md5-hash even if via nwb.config.js somehow.
Thoughts?
The text was updated successfully, but these errors were encountered: