webpack-stable-module-id-and-hash icon indicating copy to clipboard operation
webpack-stable-module-id-and-hash copied to clipboard

doesn't seem to fully solve the problem

Open jampy opened this issue 8 years ago • 2 comments

Unfortunately, the chunk hash calculated by this plugin is "too stable".

Today I added added a large subtree to my application (duplicated a subdirectory to use it as a basis for something new). This subtree got it's own Webpack "chunk", as many parts of the application are loaded on-demand.

Before the change one of the Webpack chunks was named "3-chunk-0-53-48686df03dc821ceba28b976c-en.js". After the change, a new chunk with identical name was created, but with completely different content.

This caused the Webpack runtime to request chunkId "12", which simply didn't exist.

I have no clue what could be the reason for this and what is necessary to reproduce it. Anyway, the build was sensitive to the order of my requires. Just switching one of the top requires apparently fixed the problem (switching back revealed the problem again).

Luckily, changing the seed option to a different value allows me to avoid the real problem, but obviously it's not the "solution" I would hope for.

This description probably doesn't contain enough information to track down the problem (sorry, can't provide anything more useful) - but it's probably good to take note of it...

jampy avatar Dec 06 '16 17:12 jampy

@jampy

Today I added added a large subtree to my application (duplicated a subdirectory to use it as a basis for something new). This subtree got it's own Webpack "chunk", as many parts of the application are loaded on-demand.

Before the change one of the Webpack chunks was named "3-chunk-0-53-48686df03dc821ceba28b976c-en.js". After the change, a new chunk with identical name was created, but with completely different content.

This caused the Webpack runtime to request chunkId "12", which simply didn't exist.

Util that moment (Before you fix it).

Suppose you have subtree /A (chunk A), after you duplicate A as B (chunkB), WHAT have you done? Have you edited any content in B/** which are depended on by chunkB?

If you just copy folder /A as /B and add a new entry in webpack config, then every modules source content which are denpended on by chunkB are identical with chunkA', so

  • webpack thinks here exist chunkA and chunkB
  • but one of output chunk file is covered due to same chunk-hash (depend on sorted module file content)

And changing top requires apparently in one module file of chunkB which means change depended module file content, hence output a different chunk-hash.

zhenyong avatar Dec 07 '16 04:12 zhenyong

Have you edited any content in B/** which are depended on by chunkB?

exactly

If you just copy folder /A as /B and add a new entry in webpack config

I did not add a new webpack config entry. Webpack does automatically creates a new chunk because I'm using require.ensure().

However, the chunks were not identical since they are dependent of different modules that are used in those chunks, only.

jampy avatar Dec 07 '16 08:12 jampy