Skip to content

Commit 2ed8f26

Browse files
committed
fix: don't restart application when lazy loaded code is changed in angular app with uglify option
Currently CLI has a logic to restart the application when one or more of the emitted files from webpack compilation is not hot update. When a lazy loaded code is changed in angular application and uglify option is provided, CLI always restarts the application. (as 0.js, 1.js are reported as changed). This happens due to the fact that CLI omits entry point files and runtime files from emitted files to check if all rest files are hot updates. As the lazy loaded chunks (`0.js`, `1.js`) are neither entry point files nor runtime files, they are not omitted and CLI decides that there is file that is not hot update and restarts the application. This PR changes this behavior and respects only chunk files from webpack compilation. Chunk files are all files except hot update files. Chunk files are: `runtime.js`, `tns_modules/inspector-modules.js`, `bundle.js`, `vendor.js` and all lazy loaded modules.
1 parent 3cabd7e commit 2ed8f26

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/services/webpack/webpack-compiler-service.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
4545
let result;
4646

4747
if (prepareData.hmr) {
48-
result = this.getUpdatedEmittedFiles(message.emittedFiles, message.webpackRuntimeFiles, message.entryPointFiles);
48+
result = this.getUpdatedEmittedFiles(message.emittedFiles, message.chunkFiles);
4949
} else {
5050
result = { emittedFiles: message.emittedFiles, fallbackFiles: <string[]>[], hash: "" };
5151
}
@@ -218,16 +218,13 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
218218
return args;
219219
}
220220

221-
private getUpdatedEmittedFiles(emittedFiles: string[], webpackRuntimeFiles: string[], entryPointFiles: string[]) {
221+
private getUpdatedEmittedFiles(emittedFiles: string[], chunkFiles: string[]) {
222222
let fallbackFiles: string[] = [];
223223
let hotHash;
224224
let result = emittedFiles.slice();
225225
const hotUpdateScripts = emittedFiles.filter(x => x.endsWith('.hot-update.js'));
226-
if (webpackRuntimeFiles && webpackRuntimeFiles.length) {
227-
result = result.filter(file => webpackRuntimeFiles.indexOf(file) === -1);
228-
}
229-
if (entryPointFiles && entryPointFiles.length) {
230-
result = result.filter(file => entryPointFiles.indexOf(file) === -1);
226+
if (chunkFiles && chunkFiles.length) {
227+
result = result.filter(file => chunkFiles.indexOf(file) === -1);
231228
}
232229
hotUpdateScripts.forEach(hotUpdateScript => {
233230
const { name, hash } = this.parseHotUpdateChunkName(hotUpdateScript);

lib/services/webpack/webpack.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ declare global {
3434

3535
interface IWebpackEmitMessage {
3636
emittedFiles: string[];
37-
webpackRuntimeFiles: string[];
38-
entryPointFiles: string[];
37+
chunkFiles: string[];
3938
}
4039

4140
interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectServiceBase {

0 commit comments

Comments
 (0)