diff --git a/packages/subapp-web/lib/util.js b/packages/subapp-web/lib/util.js index c6a9a51d0..d2f69250f 100644 --- a/packages/subapp-web/lib/util.js +++ b/packages/subapp-web/lib/util.js @@ -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 .bundle.js, like header.bundle.js - // but with runtimeChunk, the entry point are generated with hash - // as ..js - // So check both cases. - const matchEntry = x => x === `${entryName}.bundle.js` || x.endsWith(`.${entryName}.js`); + // + // Normal entry output bundles are generated as .bundle[.dev].js, + // like header.bundle.js + // See xarc-webpack/lib/partial/[output, dev] + // The plugin SplitChunksPlugin generate chunks with name as + // .~.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 => { diff --git a/packages/xarc-webpack/lib/partials/dev.js b/packages/xarc-webpack/lib/partials/dev.js index 789c1a46d..a44c143df 100644 --- a/packages/xarc-webpack/lib/partials/dev.js +++ b/packages/xarc-webpack/lib/partials/dev.js @@ -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 diff --git a/packages/xarc-webpack/lib/partials/output.js b/packages/xarc-webpack/lib/partials/output.js index f222ef2e0..f479ee566 100644 --- a/packages/xarc-webpack/lib/partials/output.js +++ b/packages/xarc-webpack/lib/partials/output.js @@ -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() } }); diff --git a/packages/xarc-webpack/lib/partials/subapp-chunks.js b/packages/xarc-webpack/lib/partials/subapp-chunks.js index c9d0a2a3c..cb54634ea 100644 --- a/packages/xarc-webpack/lib/partials/subapp-chunks.js +++ b/packages/xarc-webpack/lib/partials/subapp-chunks.js @@ -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 .~ to detect subapp bundles + return `${key}.~${digest}`; } function makeConfig() {