Skip to content

Commit 3b7def6

Browse files
fix: external files are not livesynced
In case you have external files set in the webpack.config.js (or resources copied with CopyWebpackPlugin), the `tns run ...` command does not LiveSync them to device. Webpack compilation is triggered, but as the emitted files are not hot updates, the hot update hash of the compilation is the same as the previous one. In this case CLI decides there's nothing to sync. To fix this extend the check in webpack-compiler-service to be based not only on the comparison between previous and current hash, but on the emitted files as well - if there are files which are not hot updates, continue the execution even if the previous and current hash are the same. That's exactly the case with externals.
1 parent 5550613 commit 3b7def6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
4949
return;
5050
}
5151

52-
// the hash of the compilation is the same as the previous one
53-
if (this.expectedHashes[platformData.platformNameLowerCase] === message.hash) {
54-
return;
55-
}
56-
52+
// Persist the previousHash value before calling `this.getUpdatedEmittedFiles` as it will modify the expectedHashes object with the current hash
53+
const previousHash = this.expectedHashes[platformData.platformNameLowerCase];
5754
let result;
5855

5956
if (prepareData.hmr) {
@@ -78,6 +75,12 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
7875
};
7976

8077
this.$logger.trace("Generated data from webpack message:", data);
78+
79+
// the hash of the compilation is the same as the previous one and there are only hot updates produced
80+
if (data.hasOnlyHotUpdateFiles && previousHash === message.hash) {
81+
return;
82+
}
83+
8184
if (data.files.length) {
8285
this.emit(WEBPACK_COMPILATION_COMPLETE, data);
8386
}

0 commit comments

Comments
 (0)