Skip to content

Commit

Permalink
fix: create same hashes on server and client
Browse files Browse the repository at this point in the history
we saw a behaviour with dynamic imports for SSR, when the import
was directly referenced, e.g. with `import(./foo')` instead of
`import('./')` webpack would with create different filehashes in
the moduleMap when the option `usedExports` is enabled.

filenames before hashing in webpack with `usedExports` followed the
pattern: `filename.js|abc`

filenames without `usedExports` are simply the filename: `filename.js`

they are then hashed in webpacks `HashedModuleIdsPlugin.js` with
different results, leading to an incomplete modulesMap

Co-authored-by: Jonas Holland <jonas.holland@new-work.se>
  • Loading branch information
robertkowalski and jhiode committed Sep 30, 2021
1 parent 23beb61 commit 63d90db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/webpack/lib/configs/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ module.exports = function getConfig(config, name, buildDependencies) {
}),
],
chunkIds: 'natural',
usedExports: true,
usedExports: false,
concatenateModules: true,
},
plugins: [
Expand Down
1 change: 1 addition & 0 deletions packages/webpack/lib/configs/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ module.exports = function getConfig(config, name, buildDependencies) {
optimization: {
minimizer: [],
chunkIds: 'natural',
usedExports: false,
},
plugins: [
new LimitChunkCountPlugin({ maxChunks: 1 }),
Expand Down

0 comments on commit 63d90db

Please sign in to comment.