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

Commit 269308b

Browse files
author
Fatme
authored
chore: merge release into master (#880)
* release: cut the 0.21.1 release (#869) * fix: add support for executing unit tests for vue projects (#839) (#870) * release: cut the 0.21.2 release (#871) * fix: ignore the Webpack runtime chunks when sending HMR updates * chore: apply PR suggestions
1 parent 19cf89f commit 269308b

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

Diff for: CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
<a name="0.21.2"></a>
2+
## [0.21.2](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.21.0...0.21.2) (2019-04-22)
3+
4+
5+
### Bug Fixes
6+
7+
* add support for executing unit tests for vue projects ([#870](https://github.com/NativeScript/nativescript-dev-webpack/issues/870)) ([c8afe9f](https://github.com/NativeScript/nativescript-dev-webpack/commit/c8afe9f))
8+
9+
10+
11+
<a name="0.21.1"></a>
12+
## [0.21.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.21.0...0.21.1) (2019-04-18)
13+
14+
15+
### Bug Fixes
16+
17+
* add support for ts files on test command when `--bundle` is provided ([#848](https://github.com/NativeScript/nativescript-dev-webpack/issues/848)) ([bd4fa9c](https://github.com/NativeScript/nativescript-dev-webpack/commit/bd4fa9c))
18+
* fix "ERROR in Must have a source file to refactor." error from ngCompilerPlugin on `test` command ([#859](https://github.com/NativeScript/nativescript-dev-webpack/issues/859)) ([196d977](https://github.com/NativeScript/nativescript-dev-webpack/commit/196d977))
19+
* typescript source maps are containing javascript code ([#857](https://github.com/NativeScript/nativescript-dev-webpack/issues/857)) ([384bee2](https://github.com/NativeScript/nativescript-dev-webpack/commit/384bee2))
20+
* use correct slashes on windows ([#851](https://github.com/NativeScript/nativescript-dev-webpack/issues/851)) ([9020c47](https://github.com/NativeScript/nativescript-dev-webpack/commit/9020c47))
21+
22+
23+
124
<a name="0.21.0"></a>
225
# [0.21.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.20.3...0.21.0) (2019-03-21)
326

Diff for: lib/compiler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $projectData, $
8080
return;
8181
}
8282

83-
const result = getUpdatedEmittedFiles(message.emittedFiles);
83+
const result = getUpdatedEmittedFiles(message.emittedFiles, message.webpackRuntimeFiles);
8484

8585
if (hookArgs.hmrData) {
8686
hookArgs.hmrData[platform] = {

Diff for: lib/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function buildEnvData($projectData, platform, env) {
3434
* if yes this is a HMR update and remove all bundle files as we don't need them to be synced,
3535
* but only the update chunks
3636
*/
37-
function getUpdatedEmittedFiles(emittedFiles) {
37+
function getUpdatedEmittedFiles(emittedFiles, webpackRuntimeFiles) {
3838
let fallbackFiles = [];
3939
let hotHash;
4040
if (emittedFiles.some(x => x.endsWith('.hot-update.json'))) {
@@ -45,6 +45,10 @@ function getUpdatedEmittedFiles(emittedFiles) {
4545
hotHash = hash;
4646
// remove bundle/vendor.js files if there's a bundle.XXX.hot-update.js or vendor.XXX.hot-update.js
4747
result = result.filter(file => file !== `${name}.js`);
48+
if (webpackRuntimeFiles && webpackRuntimeFiles.length) {
49+
// remove files containing only the Webpack runtime (e.g. runtime.js)
50+
result = result.filter(file => webpackRuntimeFiles.indexOf(file) === -1);
51+
}
4852
});
4953
//if applying of hot update fails, we must fallback to the full files
5054
fallbackFiles = emittedFiles.filter(file => result.indexOf(file) === -1);

Diff for: plugins/WatchStateLoggerPlugin.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class WatchStateLoggerPlugin {
3131
console.log(messages.compilationComplete);
3232
}
3333

34+
const runtimeOnlyFiles = getWebpackRuntimeOnlyFiles(compilation, compiler.context);
3435
let emittedFiles = Object
3536
.keys(compilation.assets)
3637
.filter(assetKey => compilation.assets[assetKey].emitted);
@@ -42,7 +43,27 @@ export class WatchStateLoggerPlugin {
4243

4344
process.send && process.send(messages.compilationComplete, error => null);
4445
// Send emitted files so they can be LiveSynced if need be
45-
process.send && process.send({ emittedFiles: emittedFilesFakePaths }, error => null);
46+
process.send && process.send({ emittedFiles: emittedFilesFakePaths, webpackRuntimeFiles: runtimeOnlyFiles }, error => null);
4647
});
4748
}
4849
}
50+
51+
function getWebpackRuntimeOnlyFiles(compilation, basePath) {
52+
let runtimeOnlyFiles = [];
53+
try {
54+
runtimeOnlyFiles = [].concat(...Array.from<any>(compilation.entrypoints.values())
55+
.map(entrypoint => entrypoint.runtimeChunk)
56+
// filter embedded runtime chunks (e.g. part of bundle.js or inspector-modules.js)
57+
.filter(runtimeChunk => !!runtimeChunk && runtimeChunk.preventIntegration)
58+
.map(runtimeChunk => runtimeChunk.files))
59+
// get only the unique files in case of "single" runtime (e.g. runtime.js)
60+
.filter((value, index, self) => self.indexOf(value) === index)
61+
// convert to absolute paths
62+
.map(fileName => join(basePath, fileName));
63+
} catch (e) {
64+
// breaking change in the Webpack API
65+
console.log("Warning: Unable to find Webpack runtime files.");
66+
}
67+
68+
return runtimeOnlyFiles;
69+
}

0 commit comments

Comments
 (0)