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

Commit a68778e

Browse files
authored
feat: enable source maps when --env.sourceMap is provided (#604)
* feat: enable source maps when the --env.sourceMap is provided * refactor: remove obsolete sourceMap arguments from compiler.js * refactor: make env.sourceMap usage consistent with other env* props
1 parent 321fb10 commit a68778e

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

Diff for: lib/compiler.js

-12
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,8 @@ exports.runWebpackCompiler = function runWebpackCompiler(config, $projectData, $
4242
const envData = buildEnvData($projectData, platform, env);
4343
const envParams = buildEnvCommandLineParams(config, envData, $logger);
4444

45-
// Adding `npm i source-map-support --save-dev` in an app will make source maps work
46-
// and stack traces will point to .ts if .ts files and proper source maps exist.
47-
let sourceMapSupportArgs = [];
48-
const appSourceMapSupportInstallPath = pathResolve(projectDir, "node_modules", "source-map-support", "register.js");
49-
const devDepSourceMapSupportInstallPath = pathResolve(__dirname, "..", "node_modules", "source-map-support", "register.js");
50-
if (existsSync(appSourceMapSupportInstallPath)) {
51-
sourceMapSupportArgs = ["--require", appSourceMapSupportInstallPath];
52-
} else if (existsSync(devDepSourceMapSupportInstallPath)) {
53-
sourceMapSupportArgs = ["--require", devDepSourceMapSupportInstallPath];
54-
}
55-
5645
const args = [
5746
"--preserve-symlinks",
58-
...sourceMapSupportArgs,
5947
pathResolve(projectDir, "node_modules", "webpack", "bin", "webpack.js"),
6048
`--config=${pathResolve(projectDir, "webpack.config.js")}`,
6149
...(config.watch ? ["--watch"] : []),

Diff for: templates/webpack.angular.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module.exports = env => {
4444
snapshot, // --env.snapshot
4545
uglify, // --env.uglify
4646
report, // --env.report
47+
sourceMap, // --env.sourceMap
4748
} = env;
4849

4950
const appFullPath = resolve(projectRoot, appPath);
@@ -100,7 +101,7 @@ module.exports = env => {
100101
"fs": "empty",
101102
"__dirname": false,
102103
},
103-
devtool: "none",
104+
devtool: sourceMap ? "inline-source-map" : "none",
104105
optimization: {
105106
splitChunks: {
106107
cacheGroups: {
@@ -229,6 +230,7 @@ module.exports = env => {
229230
entryModule: resolve(appPath, "app.module#AppModule"),
230231
tsConfigPath: join(__dirname, "tsconfig.esm.json"),
231232
skipCodeGeneration: !aot,
233+
sourceMap: !!sourceMap,
232234
}),
233235
// Does IPC communication with the {N} CLI to notify events when running in watch mode.
234236
new nsWebpack.WatchStateLoggerPlugin(),

Diff for: templates/webpack.javascript.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = env => {
3939
snapshot, // --env.snapshot
4040
uglify, // --env.uglify
4141
report, // --env.report
42+
sourceMap, // --env.sourceMap
4243
} = env;
4344

4445
const appFullPath = resolve(projectRoot, appPath);
@@ -93,7 +94,7 @@ module.exports = env => {
9394
"fs": "empty",
9495
"__dirname": false,
9596
},
96-
devtool: "none",
97+
devtool: sourceMap ? "inline-source-map" : "none",
9798
optimization: {
9899
splitChunks: {
99100
cacheGroups: {

Diff for: templates/webpack.typescript.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = env => {
3939
snapshot, // --env.snapshot
4040
uglify, // --env.uglify
4141
report, // --env.report
42+
sourceMap, // --env.sourceMap
4243
} = env;
4344

4445
const appFullPath = resolve(projectRoot, appPath);
@@ -95,7 +96,7 @@ module.exports = env => {
9596
"fs": "empty",
9697
"__dirname": false,
9798
},
98-
devtool: "none",
99+
devtool: sourceMap ? "inline-source-map" : "none",
99100
optimization: {
100101
splitChunks: {
101102
cacheGroups: {

0 commit comments

Comments
 (0)