Skip to content

Commit

Permalink
fix: remove content hash from chunk names (#1575)
Browse files Browse the repository at this point in the history
* fix: remove content hash from chunk names

* fix lint
  • Loading branch information
jchip authored Mar 26, 2020
1 parent fba51aa commit 0d44b3f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
15 changes: 9 additions & 6 deletions packages/subapp-web/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ const utils = {
const entryPoints = assets.entryPoints[entryName];
assert(entryPoints, `subapp-web: no entry point found for ${name}`);

// without webpack optimization.runtimeChunk the entry point bundles are generated
// as <entryName>.bundle.js, like header.bundle.js
// but with runtimeChunk, the entry point are generated with hash
// as <hash>.<entryName>.js
// So check both cases.
const matchEntry = x => x === `${entryName}.bundle.js` || x.endsWith(`.${entryName}.js`);
//
// Normal entry output bundles are generated as <entryName>.bundle[.dev].js,
// like header.bundle.js
// See xarc-webpack/lib/partial/[output, dev]
// The plugin SplitChunksPlugin generate chunks with name as
// <entryName>.~<hash>.bundle[.dev].js
// See xarc-webpack/lib/partial/subapp-chunks.js
//
const matchEntry = x => x.startsWith(`${entryName}.bundle`) || x.startsWith(`${entryName}.~`);
// map all IDs to actual assets
const bundleAssets = entryPoints
.map(id => {
Expand Down
3 changes: 2 additions & 1 deletion packages/xarc-webpack/lib/partials/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ module.exports = function() {
devServer: devServerConfig,
output: {
publicPath: makePublicPath(),
filename: "[name].bundle.dev.js"
filename: "[name].bundle.dev.js",
chunkFilename: "[name].bundle.dev.js"
},
devtool: "inline-source-map",
// TODO: why is this here and duplicates what's in extract-style partial? This is causing
Expand Down
4 changes: 1 addition & 3 deletions packages/xarc-webpack/lib/partials/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ module.exports = () => ({
path: getOutputPath(),
pathinfo: inspectpack, // Enable path information for inspectpack
publicPath: "/js/",
chunkFilename: babel.hasMultiTargets
? `${babel.target}.[contenthash].[name].js`
: "[contenthash].[name].js",
chunkFilename: getOutputFilename(),
filename: getOutputFilename()
}
});
4 changes: 3 additions & 1 deletion packages/xarc-webpack/lib/partials/subapp-chunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ function hashChunks(mod, chunks, key) {
digest = hash.digest("hex");
splitMap[id] = digest;
}
return `${key}~${digest}`;
digest = digest.substr(-8);
// subapp-web/lib/util.js will try to match <entryName>.~ to detect subapp bundles
return `${key}.~${digest}`;
}

function makeConfig() {
Expand Down

0 comments on commit 0d44b3f

Please sign in to comment.