diff --git a/CHANGELOG.md b/CHANGELOG.md index c52998fa..845a7224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ + +## [0.21.2](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.21.0...0.21.2) (2019-04-22) + + +### Bug Fixes + +* 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)) + + + + +## [0.21.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.21.0...0.21.1) (2019-04-18) + + +### Bug Fixes + +* 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)) +* 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)) +* 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)) +* 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)) + + + # [0.21.0](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.20.3...0.21.0) (2019-03-21) diff --git a/lib/compiler.js b/lib/compiler.js index 588edc5d..6398436c 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -80,7 +80,7 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $projectData, $ return; } - const result = getUpdatedEmittedFiles(message.emittedFiles); + const result = getUpdatedEmittedFiles(message.emittedFiles, message.webpackRuntimeFiles); if (hookArgs.hmrData) { hookArgs.hmrData[platform] = { diff --git a/lib/utils.js b/lib/utils.js index 5bb0dea2..b5341c52 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -34,7 +34,7 @@ function buildEnvData($projectData, platform, env) { * if yes this is a HMR update and remove all bundle files as we don't need them to be synced, * but only the update chunks */ -function getUpdatedEmittedFiles(emittedFiles) { +function getUpdatedEmittedFiles(emittedFiles, webpackRuntimeFiles) { let fallbackFiles = []; let hotHash; if (emittedFiles.some(x => x.endsWith('.hot-update.json'))) { @@ -45,6 +45,10 @@ function getUpdatedEmittedFiles(emittedFiles) { hotHash = hash; // remove bundle/vendor.js files if there's a bundle.XXX.hot-update.js or vendor.XXX.hot-update.js result = result.filter(file => file !== `${name}.js`); + if (webpackRuntimeFiles && webpackRuntimeFiles.length) { + // remove files containing only the Webpack runtime (e.g. runtime.js) + result = result.filter(file => webpackRuntimeFiles.indexOf(file) === -1); + } }); //if applying of hot update fails, we must fallback to the full files fallbackFiles = emittedFiles.filter(file => result.indexOf(file) === -1); diff --git a/plugins/WatchStateLoggerPlugin.ts b/plugins/WatchStateLoggerPlugin.ts index 565407c1..55cbb8ba 100644 --- a/plugins/WatchStateLoggerPlugin.ts +++ b/plugins/WatchStateLoggerPlugin.ts @@ -31,6 +31,7 @@ export class WatchStateLoggerPlugin { console.log(messages.compilationComplete); } + const runtimeOnlyFiles = getWebpackRuntimeOnlyFiles(compilation, compiler.context); let emittedFiles = Object .keys(compilation.assets) .filter(assetKey => compilation.assets[assetKey].emitted); @@ -42,7 +43,27 @@ export class WatchStateLoggerPlugin { process.send && process.send(messages.compilationComplete, error => null); // Send emitted files so they can be LiveSynced if need be - process.send && process.send({ emittedFiles: emittedFilesFakePaths }, error => null); + process.send && process.send({ emittedFiles: emittedFilesFakePaths, webpackRuntimeFiles: runtimeOnlyFiles }, error => null); }); } } + +function getWebpackRuntimeOnlyFiles(compilation, basePath) { + let runtimeOnlyFiles = []; + try { + runtimeOnlyFiles = [].concat(...Array.from(compilation.entrypoints.values()) + .map(entrypoint => entrypoint.runtimeChunk) + // filter embedded runtime chunks (e.g. part of bundle.js or inspector-modules.js) + .filter(runtimeChunk => !!runtimeChunk && runtimeChunk.preventIntegration) + .map(runtimeChunk => runtimeChunk.files)) + // get only the unique files in case of "single" runtime (e.g. runtime.js) + .filter((value, index, self) => self.indexOf(value) === index) + // convert to absolute paths + .map(fileName => join(basePath, fileName)); + } catch (e) { + // breaking change in the Webpack API + console.log("Warning: Unable to find Webpack runtime files."); + } + + return runtimeOnlyFiles; +}