Skip to content

Commit 078ddbc

Browse files
committed
bug #523 Ignore hot-update files in the SharedEntryConcatPlugin (Lyrkan, weaverryan)
This PR was merged into the master branch. Discussion ---------- Ignore hot-update files in the SharedEntryConcatPlugin This PR fixes #493. When using `dev-server --hot` an additional `.hot-update.js` file can be [added to the list of files associated to a chunk](https://github.com/webpack/webpack/blob/7076c05353bae6d788247cfcaa94704f34cca292/lib/HotModuleReplacementPlugin.js#L287). If that list contains another JS file the current version of Encore throws an Error that causes the compilation to fail. The good news is that the `.hot-update.js` file is also [added to the `additionalChunkAssets`](https://github.com/webpack/webpack/blob/7076c05353bae6d788247cfcaa94704f34cca292/lib/HotModuleReplacementPlugin.js#L284) property of the `compilation` object. This allows us to ignore it and only keep the JS file that we need. Commits ------- 5da8b70 clarifying comment 39a3c6e Ignore hot-update files in the SharedEntryConcatPlugin
2 parents 677c434 + 5da8b70 commit 078ddbc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/webpack/shared-entry-concat-plugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ function SharedEntryConcatPlugin(sharedEntryName) {
1818

1919
function getChunkFilename(compilation, chunkName) {
2020
const chunk = compilation.namedChunks.get(chunkName);
21+
// any "additional" files - like .hot-update.js when using --hot
22+
const additionalChunkAssets = compilation.additionalChunkAssets || [];
2123

2224
if (!chunk) {
2325
throw new Error(`Cannot find chunk ${chunkName}`);
2426
}
2527

2628
const jsFiles = chunk.files.filter(filename => {
27-
return /\.js$/.test(filename);
29+
return /\.js$/.test(filename) && !additionalChunkAssets.includes(filename);
2830
});
2931

3032
if (jsFiles.length !== 1) {

0 commit comments

Comments
 (0)