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

feat: enable source maps when --env.sourceMap is provided #604

Merged
merged 4 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"] : []),
Expand Down
4 changes: 3 additions & 1 deletion templates/webpack.angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -100,7 +101,7 @@ module.exports = env => {
"fs": "empty",
"__dirname": false,
},
devtool: "none",
devtool: sourceMap ? "inline-source-map" : "none",
optimization: {
splitChunks: {
cacheGroups: {
Expand Down Expand Up @@ -229,6 +230,7 @@ module.exports = env => {
entryModule: resolve(appPath, "app.module#AppModule"),
tsConfigPath: join(__dirname, "tsconfig.esm.json"),
skipCodeGeneration: !aot,
sourceMap: !!sourceMap,
}),
// Does IPC communication with the {N} CLI to notify events when running in watch mode.
new nsWebpack.WatchStateLoggerPlugin(),
Expand Down
3 changes: 2 additions & 1 deletion templates/webpack.javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -93,7 +94,7 @@ module.exports = env => {
"fs": "empty",
"__dirname": false,
},
devtool: "none",
devtool: sourceMap ? "inline-source-map" : "none",
optimization: {
splitChunks: {
cacheGroups: {
Expand Down
3 changes: 2 additions & 1 deletion templates/webpack.typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -95,7 +96,7 @@ module.exports = env => {
"fs": "empty",
"__dirname": false,
},
devtool: "none",
devtool: sourceMap ? "inline-source-map" : "none",
optimization: {
splitChunks: {
cacheGroups: {
Expand Down