Skip to content

Commit 013817b

Browse files
committed
fix: emit only bundle.<hash>.hot-update.js and <hash>.hot-update.json files
Currently `inspector.modules.js` file is reported on change and this led to the problem that `inspcector-modules.js` file is transferred on every sync. As we need to transfer only `.hot-update` files when `--hmr` is provided, we should exclude all other files.
1 parent aad09a3 commit 013817b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
3737
return;
3838
}
3939

40-
const result = this.getUpdatedEmittedFiles(message.emittedFiles, message.webpackRuntimeFiles);
40+
const result = this.getUpdatedEmittedFiles(message.emittedFiles, message.webpackRuntimeFiles, message.entryPointFiles);
4141

4242
const files = result.emittedFiles
43-
.filter((file: string) => file.indexOf("App_Resources") === -1)
4443
.map((file: string) => path.join(platformData.appDestinationDirectoryPath, "app", file));
4544

4645
const data = {
@@ -173,23 +172,25 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
173172
return args;
174173
}
175174

176-
private getUpdatedEmittedFiles(emittedFiles: string[], webpackRuntimeFiles: string[]) {
175+
private getUpdatedEmittedFiles(emittedFiles: string[], webpackRuntimeFiles: string[], entryPointFiles: string[]) {
177176
let fallbackFiles: string[] = [];
178177
let hotHash;
179178
if (emittedFiles.some(x => x.endsWith('.hot-update.json'))) {
180179
let result = emittedFiles.slice();
181180
const hotUpdateScripts = emittedFiles.filter(x => x.endsWith('.hot-update.js'));
181+
if (webpackRuntimeFiles && webpackRuntimeFiles.length) {
182+
result = result.filter(file => webpackRuntimeFiles.indexOf(file) === -1);
183+
}
184+
if (entryPointFiles && entryPointFiles.length) {
185+
result = result.filter(file => entryPointFiles.indexOf(file) === -1);
186+
}
182187
hotUpdateScripts.forEach(hotUpdateScript => {
183188
const { name, hash } = this.parseHotUpdateChunkName(hotUpdateScript);
184189
hotHash = hash;
185190
// remove bundle/vendor.js files if there's a bundle.XXX.hot-update.js or vendor.XXX.hot-update.js
186191
result = result.filter(file => file !== `${name}.js`);
187-
if (webpackRuntimeFiles && webpackRuntimeFiles.length) {
188-
// remove files containing only the Webpack runtime (e.g. runtime.js)
189-
result = result.filter(file => webpackRuntimeFiles.indexOf(file) === -1);
190-
}
191192
});
192-
//if applying of hot update fails, we must fallback to the full files
193+
// if applying of hot update fails, we must fallback to the full files
193194
fallbackFiles = emittedFiles.filter(file => result.indexOf(file) === -1);
194195
return { emittedFiles: result, fallbackFiles, hash: hotHash };
195196
}

0 commit comments

Comments
 (0)