diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2087e5..5438c98c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +<a name="0.20.3"></a> +## [0.20.3](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.20.2...0.20.3) (2019-03-14) + + +### Bug Fixes + +* initial compilation always generates same compilation hash ([#815](https://github.com/NativeScript/nativescript-dev-webpack/issues/815)) ([ba6d896](https://github.com/NativeScript/nativescript-dev-webpack/commit/ba6d896)) +* show message for stopping webpack only when it has been started ([#821](https://github.com/NativeScript/nativescript-dev-webpack/issues/821)) ([1bd18e5](https://github.com/NativeScript/nativescript-dev-webpack/commit/1bd18e5)) +* **HMR:** modulePath on Windows to apply changes in app styles at runtime ([#807](https://github.com/NativeScript/nativescript-dev-webpack/issues/807)) ([cc55d4f](https://github.com/NativeScript/nativescript-dev-webpack/commit/cc55d4f)) + + +### Features + +* **Vue:** option to enable sourcemaps ([#774](https://github.com/NativeScript/nativescript-dev-webpack/issues/774)) ([70cd58a](https://github.com/NativeScript/nativescript-dev-webpack/commit/70cd58a)) + + + <a name="0.20.1"></a> ## [0.20.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.20.0...0.20.1) (2019-02-18) diff --git a/dependencyManager.js b/dependencyManager.js index da804618..0663b8ee 100644 --- a/dependencyManager.js +++ b/dependencyManager.js @@ -84,11 +84,11 @@ function getRequiredDeps(packageJson) { } const deps = { - "@angular/compiler-cli": "~7.1.0", + "@angular/compiler-cli": "~7.2.0", }; if (!dependsOn(packageJson, "@angular-devkit/build-angular")) { - deps["@ngtools/webpack"] = "~7.1.0"; + deps["@ngtools/webpack"] = "~7.2.0"; } return deps; diff --git a/lib/after-watch.js b/lib/after-watch.js index 421f748d..85e8cb20 100644 --- a/lib/after-watch.js +++ b/lib/after-watch.js @@ -2,8 +2,7 @@ const { stopWebpackCompiler } = require('./compiler'); const { removeListener } = require("./utils"); module.exports = function($logger, $liveSyncService) { - $logger.info("Stopping webpack watch"); - stopWebpackCompiler(); + stopWebpackCompiler($logger); removeListener($liveSyncService, "liveSyncStopped"); removeListener(process, "exit"); } diff --git a/lib/before-watch.js b/lib/before-watch.js index 5d65310f..84ba260d 100644 --- a/lib/before-watch.js +++ b/lib/before-watch.js @@ -10,11 +10,11 @@ module.exports = function ($logger, $liveSyncService, $devicesService, hookArgs) Object.keys(webpackProcesses).forEach(platform => { const devices = $devicesService.getDevicesForPlatform(platform); if (!devices || !devices.length) { - stopWebpackCompiler(platform); + stopWebpackCompiler($logger, platform); } }); }); - addListener(process, "exit", stopWebpackCompiler); + addListener(process, "exit", () => stopWebpackCompiler($logger)); const platforms = hookArgs.config.platforms; return Promise.all(platforms.map(platform => { diff --git a/lib/compiler.js b/lib/compiler.js index eeb1515c..625fc75d 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -123,11 +123,11 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $projectData, $ } } -exports.stopWebpackCompiler = function stopWebpackCompiler(platform) { +exports.stopWebpackCompiler = function stopWebpackCompiler($logger, platform) { if (platform) { - stopWebpackForPlatform(platform); + stopWebpackForPlatform($logger, platform); } else { - Object.keys(webpackProcesses).forEach(platform => stopWebpackForPlatform(platform)); + Object.keys(webpackProcesses).forEach(platform => stopWebpackForPlatform($logger, platform)); } } @@ -171,9 +171,11 @@ function logSnapshotWarningMessage($logger) { } } -function stopWebpackForPlatform(platform) { +function stopWebpackForPlatform($logger, platform) { + $logger.trace(`Stopping webpack watch for platform ${platform}.`); const webpackProcess = webpackProcesses[platform]; webpackProcess.kill("SIGINT"); + delete webpackProcesses[platform]; } diff --git a/lib/utils.js b/lib/utils.js index 36baaf1d..5bb0dea2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,10 +1,8 @@ const os = require("os"); -const path = require("path"); const { getAppPathFromProjectData, getAppResourcesPathFromProjectData, - getProjectDir, isAndroid, } = require("../projectHelpers"); @@ -92,6 +90,10 @@ function removeListener(eventEmitter, name) { } } +function convertToUnixPath(relativePath) { + return relativePath.replace(/\\/g, "/"); +} + module.exports = { buildEnvData, debuggingEnabled, @@ -99,5 +101,6 @@ module.exports = { getUpdatedEmittedFiles, parseHotUpdateChunkName, addListener, - removeListener + removeListener, + convertToUnixPath }; diff --git a/markup-hot-loader.js b/markup-hot-loader.js index 6d0ffd0a..e811dd5d 100644 --- a/markup-hot-loader.js +++ b/markup-hot-loader.js @@ -1,7 +1,9 @@ const { reload } = require("./hot-loader-helper"); +const { convertToUnixPath } = require("./lib/utils"); module.exports = function (source) { const typeMarkup = "markup"; - const modulePath = this.resourcePath.replace(this.rootContext, "."); + const moduleRelativePath = this.resourcePath.replace(this.rootContext, "."); + const modulePath = convertToUnixPath(moduleRelativePath); return `${source};${reload({ type: typeMarkup, path: modulePath })}`; }; diff --git a/package.json b/package.json index a9436128..bf2671c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-dev-webpack", - "version": "0.20.1", + "version": "0.20.3", "main": "index", "description": "", "homepage": "http://www.telerik.com", diff --git a/script-hot-loader.js b/script-hot-loader.js index be828359..b9d07416 100644 --- a/script-hot-loader.js +++ b/script-hot-loader.js @@ -1,7 +1,9 @@ const { reload } = require("./hot-loader-helper"); +const { convertToUnixPath } = require("./lib/utils"); module.exports = function (source) { const typeScript = "script"; - const modulePath = this.resourcePath.replace(this.rootContext, "."); + const moduleRelativePath = this.resourcePath.replace(this.rootContext, "."); + const modulePath = convertToUnixPath(moduleRelativePath); return `${source};${reload({ type: typeScript, path: modulePath })}`; }; diff --git a/style-hot-loader.js b/style-hot-loader.js index e581cfbd..c4c3822a 100644 --- a/style-hot-loader.js +++ b/style-hot-loader.js @@ -1,7 +1,9 @@ const { reload } = require("./hot-loader-helper"); +const { convertToUnixPath } = require("./lib/utils"); module.exports = function (source) { const typeStyle = "style"; - const modulePath = this.resourcePath.replace(this.rootContext, "."); + const moduleRelativePath = this.resourcePath.replace(this.rootContext, "."); + const modulePath = convertToUnixPath(moduleRelativePath); return `${source};${reload({ type: typeStyle, path: modulePath })}`; }; diff --git a/templates/webpack.angular.js b/templates/webpack.angular.js index 64d6087e..cf54f9d9 100644 --- a/templates/webpack.angular.js +++ b/templates/webpack.angular.js @@ -13,6 +13,7 @@ const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); const { AngularCompilerPlugin } = require("@ngtools/webpack"); +const hashSalt = Date.now().toString(); module.exports = env => { // Add your custom Activities, Services and other Android app components here. @@ -109,6 +110,7 @@ module.exports = env => { libraryTarget: "commonjs2", filename: "[name].js", globalObject: "global", + hashSalt }, resolve: { extensions: [".ts", ".js", ".scss", ".css"], diff --git a/templates/webpack.javascript.js b/templates/webpack.javascript.js index 780e9ecd..1999aa62 100644 --- a/templates/webpack.javascript.js +++ b/templates/webpack.javascript.js @@ -8,6 +8,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); +const hashSalt = Date.now().toString(); module.exports = env => { // Add your custom Activities, Services and other android app components here. @@ -71,6 +72,7 @@ module.exports = env => { libraryTarget: "commonjs2", filename: "[name].js", globalObject: "global", + hashSalt }, resolve: { extensions: [".js", ".scss", ".css"], diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index 913977c9..460a4f37 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -8,6 +8,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); +const hashSalt = Date.now().toString(); module.exports = env => { // Add your custom Activities, Services and other Android app components here. @@ -71,6 +72,7 @@ module.exports = env => { libraryTarget: "commonjs2", filename: "[name].js", globalObject: "global", + hashSalt }, resolve: { extensions: [".ts", ".js", ".scss", ".css"], diff --git a/templates/webpack.vue.js b/templates/webpack.vue.js index 18a09ff3..946ba10e 100644 --- a/templates/webpack.vue.js +++ b/templates/webpack.vue.js @@ -12,6 +12,7 @@ const NsVueTemplateCompiler = require("nativescript-vue-template-compiler"); const nsWebpack = require("nativescript-dev-webpack"); const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); +const hashSalt = Date.now().toString(); module.exports = env => { // Add your custom Activities, Services and other android app components here. @@ -44,6 +45,7 @@ module.exports = env => { production, // --env.production report, // --env.report hmr, // --env.hmr + sourceMap, // --env.sourceMap } = env; const externals = nsWebpack.getConvertedExternals(env.externals); @@ -79,6 +81,7 @@ module.exports = env => { libraryTarget: "commonjs2", filename: "[name].js", globalObject: "global", + hashSalt }, resolve: { extensions: [".vue", ".ts", ".js", ".scss", ".css"], @@ -109,7 +112,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: "none", + devtool: sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: {