Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
fix: hmr should work with uglify (#953)
Browse files Browse the repository at this point in the history
Currently `hmr` with `--env.uglify` is not working as the uglifier touches all files. This leads to emit of files that are not hot updates. When CLI finds such files, it decides hmr is not successful and restarts the application.
However, some of the emitted files are not actully changed. These emitted (and not changed) files are chunks of the entry points - as we are with HMR if there's an actual change for them, we'll receive hot-update files.
Currently there's a logic to skip all emitted entry points and webpack runtime files (`runtime.js`) when we are with HMR. To fix the current issue, extend this logic to skip emitted chunks of entry points as well  when we are with HMR and there's no hot-update for them.
  • Loading branch information
rosen-vladimirov authored Jun 27, 2019
1 parent 4bbf839 commit 874e4f8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/WatchStateLoggerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ function getWebpackRuntimeOnlyFiles(compilation) {
function getEntryPointFiles(compilation) {
const entryPointFiles = [];
try {
Array.from(compilation.entrypoints.values())
Array.from(compilation.entrypoints.values())
.forEach((entrypoint: any) => {
const entryChunk = entrypoint.chunks.find(chunk => chunk.name === entrypoint.options.name);
if (entryChunk) {
for (const entryChunk of entrypoint.chunks) {
entryChunk.files.forEach(fileName => {
if (fileName.indexOf("hot-update") === -1) {
entryPointFiles.push(fileName);
Expand All @@ -79,5 +78,6 @@ function getEntryPointFiles(compilation) {
console.log("Warning: Unable to find Webpack entry point files.");
}

return entryPointFiles;
return entryPointFiles
.filter((value, index, self) => self.indexOf(value) === index); // get only the unique files
}

0 comments on commit 874e4f8

Please sign in to comment.