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

Commit b00fcdd

Browse files
authored
Merge pull request #957 from NativeScript/fatme/fix-ng-uglify
fix: don't restart application when lazy loaded code is changed in angular app with uglify option
2 parents f558607 + 121c3b2 commit b00fcdd

File tree

1 file changed

+12
-35
lines changed

1 file changed

+12
-35
lines changed

plugins/WatchStateLoggerPlugin.ts

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,51 +33,28 @@ export class WatchStateLoggerPlugin {
3333
.keys(compilation.assets)
3434
.filter(assetKey => compilation.assets[assetKey].emitted);
3535

36-
const webpackRuntimeFiles = getWebpackRuntimeOnlyFiles(compilation);
37-
const entryPointFiles = getEntryPointFiles(compilation);
36+
const chunkFiles = getChunkFiles(compilation);
3837

3938
process.send && process.send(messages.compilationComplete, error => null);
4039
// Send emitted files so they can be LiveSynced if need be
41-
process.send && process.send({ emittedFiles, webpackRuntimeFiles, entryPointFiles }, error => null);
40+
process.send && process.send({ emittedFiles, chunkFiles }, error => null);
4241
});
4342
}
4443
}
4544

46-
function getWebpackRuntimeOnlyFiles(compilation) {
47-
let runtimeOnlyFiles = [];
45+
function getChunkFiles(compilation) {
46+
const chunkFiles = [];
4847
try {
49-
runtimeOnlyFiles = [].concat(...Array.from<any>(compilation.entrypoints.values())
50-
.map(entrypoint => entrypoint.runtimeChunk)
51-
// filter embedded runtime chunks (e.g. part of bundle.js or inspector-modules.js)
52-
.filter(runtimeChunk => !!runtimeChunk && runtimeChunk.preventIntegration)
53-
.map(runtimeChunk => runtimeChunk.files))
54-
// get only the unique files in case of "single" runtime (e.g. runtime.js)
55-
.filter((value, index, self) => self.indexOf(value) === index);
56-
} catch (e) {
57-
// breaking change in the Webpack API
58-
console.log("Warning: Unable to find Webpack runtime files.");
59-
}
60-
61-
return runtimeOnlyFiles;
62-
}
63-
64-
function getEntryPointFiles(compilation) {
65-
const entryPointFiles = [];
66-
try {
67-
Array.from(compilation.entrypoints.values())
68-
.forEach((entrypoint: any) => {
69-
for (const entryChunk of entrypoint.chunks) {
70-
entryChunk.files.forEach(fileName => {
71-
if (fileName.indexOf("hot-update") === -1) {
72-
entryPointFiles.push(fileName);
73-
}
74-
});
48+
compilation.chunks.forEach(chunk => {
49+
chunk.files.forEach(file => {
50+
if (file.indexOf("hot-update") === -1) {
51+
chunkFiles.push(file);
7552
}
7653
});
54+
});
7755
} catch (e) {
78-
console.log("Warning: Unable to find Webpack entry point files.");
56+
console.log("Warning: Unable to find chunk files.");
7957
}
8058

81-
return entryPointFiles
82-
.filter((value, index, self) => self.indexOf(value) === index); // get only the unique files
83-
}
59+
return chunkFiles;
60+
}

0 commit comments

Comments
 (0)