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

Commit

Permalink
fix: show proper stack traces from uglified code (split by new line i…
Browse files Browse the repository at this point in the history
…nstead of semicolon)
  • Loading branch information
DimitarTachev committed Apr 15, 2019
1 parent 621090a commit 0ae6030
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
6 changes: 4 additions & 2 deletions templates/webpack.angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = env => {
unitTesting, // --env.unitTesting
} = env;

const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
const externals = nsWebpack.getConvertedExternals(env.externals);
const appFullPath = resolve(projectRoot, appPath);
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
Expand Down Expand Up @@ -93,7 +94,7 @@ module.exports = env => {
mainPath: join(appFullPath, entryModule),
tsConfigPath: join(__dirname, tsConfigName),
skipCodeGeneration: !aot,
sourceMap: !!sourceMap,
sourceMap: !!isAnySourceMapEnabled,
additionalLazyModuleResources: additionalLazyModuleResources
});

Expand Down Expand Up @@ -168,10 +169,11 @@ module.exports = env => {
new TerserPlugin({
parallel: true,
cache: true,
sourceMap: !!sourceMap || !!hiddenSourceMap,
sourceMap: isAnySourceMapEnabled,
terserOptions: {
output: {
comments: false,
semicolons: !isAnySourceMapEnabled
},
compress: {
// The Android SBG has problems parsing the output
Expand Down
6 changes: 6 additions & 0 deletions templates/webpack.config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ describe('webpack.config.js', () => {

expect(config.devtool).toEqual("none");
expect(uglifyJsOptions.sourceMap).toBeFalsy();
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeTruthy();
expect(config.output.sourceMapFilename).toEqual("[file].map");
});

Expand All @@ -283,6 +284,7 @@ describe('webpack.config.js', () => {

expect(config.devtool).toEqual("inline-source-map");
expect(uglifyJsOptions.sourceMap).toBeTruthy();
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeFalsy();
expect(config.output.sourceMapFilename).toEqual("[file].map");
});
});
Expand All @@ -300,6 +302,7 @@ describe('webpack.config.js', () => {

expect(config.devtool).toEqual("none");
expect(uglifyJsOptions.sourceMap).toBeFalsy();
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeTruthy();
expect(config.output.sourceMapFilename).toEqual("[file].map");
});

Expand All @@ -310,6 +313,7 @@ describe('webpack.config.js', () => {

expect(config.devtool).toEqual("hidden-source-map");
expect(uglifyJsOptions.sourceMap).toBeTruthy();
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeFalsy();
expect(config.output.sourceMapFilename).toEqual(join("..", "sourceMap", "[file].map"));
});

Expand All @@ -320,6 +324,7 @@ describe('webpack.config.js', () => {

expect(config.devtool).toEqual("hidden-source-map");
expect(uglifyJsOptions.sourceMap).toBeTruthy();
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeFalsy();
expect(config.output.sourceMapFilename).toEqual(join("..", "sourceMap", "[file].map"));
});

Expand All @@ -331,6 +336,7 @@ describe('webpack.config.js', () => {

expect(config.devtool).toEqual("hidden-source-map");
expect(uglifyJsOptions.sourceMap).toBeTruthy();
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeFalsy();
expect(config.output.sourceMapFilename).toEqual(join("..", newSourceMapFolder, "[file].map"));
});
});
Expand Down
6 changes: 4 additions & 2 deletions templates/webpack.javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ module.exports = env => {
hmr, // --env.hmr,
unitTesting, // --env.unitTesting
} = env;
const externals = nsWebpack.getConvertedExternals(env.externals);

const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
const externals = nsWebpack.getConvertedExternals(env.externals);
const appFullPath = resolve(projectRoot, appPath);
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);

Expand Down Expand Up @@ -129,10 +130,11 @@ module.exports = env => {
new TerserPlugin({
parallel: true,
cache: true,
sourceMap: !!sourceMap || !!hiddenSourceMap,
sourceMap: isAnySourceMapEnabled,
terserOptions: {
output: {
comments: false,
semicolons: !isAnySourceMapEnabled
},
compress: {
// The Android SBG has problems parsing the output
Expand Down
6 changes: 4 additions & 2 deletions templates/webpack.typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = env => {
hmr, // --env.hmr,
unitTesting, // --env.unitTesting
} = env;
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
const externals = nsWebpack.getConvertedExternals(env.externals);

const appFullPath = resolve(projectRoot, appPath);
Expand Down Expand Up @@ -131,10 +132,11 @@ module.exports = env => {
new TerserPlugin({
parallel: true,
cache: true,
sourceMap: !!sourceMap || !!hiddenSourceMap,
sourceMap: isAnySourceMapEnabled,
terserOptions: {
output: {
comments: false,
semicolons: !isAnySourceMapEnabled
},
compress: {
// The Android SBG has problems parsing the output
Expand Down Expand Up @@ -207,7 +209,7 @@ module.exports = env => {
configFile: "tsconfig.tns.json",
allowTsInNodeModules: true,
compilerOptions: {
sourceMap
sourceMap: isAnySourceMapEnabled
}
},
}
Expand Down
4 changes: 3 additions & 1 deletion templates/webpack.vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = env => {
unitTesting, // --env.unitTesting
} = env;

const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
const externals = nsWebpack.getConvertedExternals(env.externals);

const mode = production ? "production" : "development"
Expand Down Expand Up @@ -142,10 +143,11 @@ module.exports = env => {
new TerserPlugin({
parallel: true,
cache: true,
sourceMap: !!sourceMap || !!hiddenSourceMap,
sourceMap: isAnySourceMapEnabled,
terserOptions: {
output: {
comments: false,
semicolons: !isAnySourceMapEnabled
},
compress: {
// The Android SBG has problems parsing the output
Expand Down

0 comments on commit 0ae6030

Please sign in to comment.