From bf1cc3391f21b7c14bf5b825e5eda5f270b80fe9 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Wed, 20 Feb 2019 13:50:04 +0200 Subject: [PATCH 1/7] release: cut the 0.20.2 (#810) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a9436128..c9ac08c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-dev-webpack", - "version": "0.20.1", + "version": "0.20.2", "main": "index", "description": "", "homepage": "http://www.telerik.com", From cc55d4fee0c6b92d6d21b7fa0fc7e174b5108c86 Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Wed, 20 Feb 2019 18:34:12 +0200 Subject: [PATCH 2/7] fix(HMR): modulePath on Windows to apply changes in app styles at runtime (#807) * fix(HMR): modulePath on Windows Replace backslashes with forward slashes. * refactor: rename a method --- lib/utils.js | 9 ++++++--- markup-hot-loader.js | 4 +++- script-hot-loader.js | 4 +++- style-hot-loader.js | 4 +++- 4 files changed, 15 insertions(+), 6 deletions(-) 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/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 })}`; }; From d1345f2ae0f2367082b9be82e36006919587e16d Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Thu, 21 Feb 2019 17:00:04 +0200 Subject: [PATCH 3/7] chore: bump version to 0.20.3 (#818) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9ac08c3..bf2671c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-dev-webpack", - "version": "0.20.2", + "version": "0.20.3", "main": "index", "description": "", "homepage": "http://www.telerik.com", From ba6d896463afa1c057bc76dc03073065760e950b Mon Sep 17 00:00:00 2001 From: Kristian Dimitrov Date: Thu, 21 Feb 2019 08:13:41 -0800 Subject: [PATCH 4/7] fix: initial compilation always generates same compilation hash (#815) --- templates/webpack.angular.js | 2 ++ templates/webpack.javascript.js | 2 ++ templates/webpack.typescript.js | 2 ++ templates/webpack.vue.js | 2 ++ 4 files changed, 8 insertions(+) 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..a07fa923 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. @@ -79,6 +80,7 @@ module.exports = env => { libraryTarget: "commonjs2", filename: "[name].js", globalObject: "global", + hashSalt }, resolve: { extensions: [".vue", ".ts", ".js", ".scss", ".css"], From 70cd58a55b3d51a8594e546c76cc4ff1f04c75ca Mon Sep 17 00:00:00 2001 From: Sam Garson Date: Fri, 22 Feb 2019 14:19:03 +0000 Subject: [PATCH 5/7] feat(Vue): option to enable sourcemaps (#774) --- templates/webpack.vue.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/webpack.vue.js b/templates/webpack.vue.js index a07fa923..946ba10e 100644 --- a/templates/webpack.vue.js +++ b/templates/webpack.vue.js @@ -45,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); @@ -111,7 +112,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: "none", + devtool: sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: { From 1bd18e59190ac83c51cf191fed33347697dbbd54 Mon Sep 17 00:00:00 2001 From: Rosen Vladimirov Date: Mon, 11 Mar 2019 03:45:02 -0700 Subject: [PATCH 6/7] fix: show message for stopping webpack only when it has been started (#821) Currently the message `Stopping webpack watch` is printed whenever CLI executes `after-watch` hooks, i.e. when user runs `tns run ` and sends Ctrl+C, the message is shown. However, we have not started any webpack process, so there's nothing to stop. Print the message only when webpack process had been started. Also print it only when `--log trace` is used. --- lib/after-watch.js | 3 +-- lib/before-watch.js | 4 ++-- lib/compiler.js | 10 ++++++---- 3 files changed, 9 insertions(+), 8 deletions(-) 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]; } From 968551b8fa4b4638655c4ab4010265054176fb68 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Thu, 14 Mar 2019 21:52:59 +0200 Subject: [PATCH 7/7] release: cut the 0.20.3 release (#831) --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2087e5..5438c98c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ + +## [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)) + + + ## [0.20.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.20.0...0.20.1) (2019-02-18)