From 7005749a641211f97947cf7e9ec8afed3166c4f1 Mon Sep 17 00:00:00 2001 From: sis0k0 Date: Fri, 6 Jul 2018 15:09:07 +0300 Subject: [PATCH 1/3] feat: enable source maps when the --env.sourceMap is provided --- templates/webpack.angular.js | 3 ++- templates/webpack.javascript.js | 2 +- templates/webpack.typescript.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/webpack.angular.js b/templates/webpack.angular.js index 97c3beb2..74bc52d4 100644 --- a/templates/webpack.angular.js +++ b/templates/webpack.angular.js @@ -100,7 +100,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: "none", + devtool: env.sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: { @@ -229,6 +229,7 @@ module.exports = env => { entryModule: resolve(appPath, "app.module#AppModule"), tsConfigPath: join(__dirname, "tsconfig.esm.json"), skipCodeGeneration: !aot, + sourceMap: !!env.sourceMap, }), // Does IPC communication with the {N} CLI to notify events when running in watch mode. new nsWebpack.WatchStateLoggerPlugin(), diff --git a/templates/webpack.javascript.js b/templates/webpack.javascript.js index 1700a92f..19eb59ee 100644 --- a/templates/webpack.javascript.js +++ b/templates/webpack.javascript.js @@ -93,7 +93,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: "none", + devtool: env.sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: { diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index 7394c84d..764e2bf2 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -95,7 +95,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: "none", + devtool: env.sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: { From 5dd1345280c0bd82603f3e264393a4351eef0bdb Mon Sep 17 00:00:00 2001 From: sis0k0 Date: Fri, 6 Jul 2018 15:11:27 +0300 Subject: [PATCH 2/3] refactor: remove obsolete sourceMap arguments from compiler.js --- lib/compiler.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 227d7a93..c2c00f27 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -42,20 +42,8 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $projectData, $ const envData = buildEnvData($projectData, platform, env); const envParams = buildEnvCommandLineParams(config, envData, $logger); - // Adding `npm i source-map-support --save-dev` in an app will make source maps work - // and stack traces will point to .ts if .ts files and proper source maps exist. - let sourceMapSupportArgs = []; - const appSourceMapSupportInstallPath = pathResolve(projectDir, "node_modules", "source-map-support", "register.js"); - const devDepSourceMapSupportInstallPath = pathResolve(__dirname, "..", "node_modules", "source-map-support", "register.js"); - if (existsSync(appSourceMapSupportInstallPath)) { - sourceMapSupportArgs = ["--require", appSourceMapSupportInstallPath]; - } else if (existsSync(devDepSourceMapSupportInstallPath)) { - sourceMapSupportArgs = ["--require", devDepSourceMapSupportInstallPath]; - } - const args = [ "--preserve-symlinks", - ...sourceMapSupportArgs, pathResolve(projectDir, "node_modules", "webpack", "bin", "webpack.js"), `--config=${pathResolve(projectDir, "webpack.config.js")}`, ...(config.watch ? ["--watch"] : []), From 39cf1a33b82122dac7d03d26ff0a4a17d2dfe298 Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Mon, 9 Jul 2018 11:43:53 +0300 Subject: [PATCH 3/3] refactor: make env.sourceMap usage consistent with other env* props --- templates/webpack.angular.js | 5 +++-- templates/webpack.javascript.js | 3 ++- templates/webpack.typescript.js | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/templates/webpack.angular.js b/templates/webpack.angular.js index 74bc52d4..2a594d42 100644 --- a/templates/webpack.angular.js +++ b/templates/webpack.angular.js @@ -44,6 +44,7 @@ module.exports = env => { snapshot, // --env.snapshot uglify, // --env.uglify report, // --env.report + sourceMap, // --env.sourceMap } = env; const appFullPath = resolve(projectRoot, appPath); @@ -100,7 +101,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: env.sourceMap ? "inline-source-map" : "none", + devtool: sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: { @@ -229,7 +230,7 @@ module.exports = env => { entryModule: resolve(appPath, "app.module#AppModule"), tsConfigPath: join(__dirname, "tsconfig.esm.json"), skipCodeGeneration: !aot, - sourceMap: !!env.sourceMap, + sourceMap: !!sourceMap, }), // Does IPC communication with the {N} CLI to notify events when running in watch mode. new nsWebpack.WatchStateLoggerPlugin(), diff --git a/templates/webpack.javascript.js b/templates/webpack.javascript.js index 19eb59ee..37251794 100644 --- a/templates/webpack.javascript.js +++ b/templates/webpack.javascript.js @@ -39,6 +39,7 @@ module.exports = env => { snapshot, // --env.snapshot uglify, // --env.uglify report, // --env.report + sourceMap, // --env.sourceMap } = env; const appFullPath = resolve(projectRoot, appPath); @@ -93,7 +94,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: env.sourceMap ? "inline-source-map" : "none", + devtool: sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: { diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index 764e2bf2..79ee37a5 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -39,6 +39,7 @@ module.exports = env => { snapshot, // --env.snapshot uglify, // --env.uglify report, // --env.report + sourceMap, // --env.sourceMap } = env; const appFullPath = resolve(projectRoot, appPath); @@ -95,7 +96,7 @@ module.exports = env => { "fs": "empty", "__dirname": false, }, - devtool: env.sourceMap ? "inline-source-map" : "none", + devtool: sourceMap ? "inline-source-map" : "none", optimization: { splitChunks: { cacheGroups: {