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

Commit 6d7f5c2

Browse files
committed
fix: show proper stack traces from uglified code (split by new line instead of semicolon)
1 parent 621090a commit 6d7f5c2

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

Diff for: templates/webpack.angular.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module.exports = env => {
5252
unitTesting, // --env.unitTesting
5353
} = env;
5454

55+
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
5556
const externals = nsWebpack.getConvertedExternals(env.externals);
5657
const appFullPath = resolve(projectRoot, appPath);
5758
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
@@ -93,7 +94,7 @@ module.exports = env => {
9394
mainPath: join(appFullPath, entryModule),
9495
tsConfigPath: join(__dirname, tsConfigName),
9596
skipCodeGeneration: !aot,
96-
sourceMap: !!sourceMap,
97+
sourceMap: !!isAnySourceMapEnabled,
9798
additionalLazyModuleResources: additionalLazyModuleResources
9899
});
99100

@@ -168,10 +169,11 @@ module.exports = env => {
168169
new TerserPlugin({
169170
parallel: true,
170171
cache: true,
171-
sourceMap: !!sourceMap || !!hiddenSourceMap,
172+
sourceMap: isAnySourceMapEnabled,
172173
terserOptions: {
173174
output: {
174175
comments: false,
176+
semicolons: !isAnySourceMapEnabled
175177
},
176178
compress: {
177179
// The Android SBG has problems parsing the output

Diff for: templates/webpack.config.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ describe('webpack.config.js', () => {
273273

274274
expect(config.devtool).toEqual("none");
275275
expect(uglifyJsOptions.sourceMap).toBeFalsy();
276+
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeTruthy();
276277
expect(config.output.sourceMapFilename).toEqual("[file].map");
277278
});
278279

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

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

301303
expect(config.devtool).toEqual("none");
302304
expect(uglifyJsOptions.sourceMap).toBeFalsy();
305+
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeTruthy();
303306
expect(config.output.sourceMapFilename).toEqual("[file].map");
304307
});
305308

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

311314
expect(config.devtool).toEqual("hidden-source-map");
312315
expect(uglifyJsOptions.sourceMap).toBeTruthy();
316+
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeFalsy();
313317
expect(config.output.sourceMapFilename).toEqual(join("..", "sourceMap", "[file].map"));
314318
});
315319

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

321325
expect(config.devtool).toEqual("hidden-source-map");
322326
expect(uglifyJsOptions.sourceMap).toBeTruthy();
327+
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeFalsy();
323328
expect(config.output.sourceMapFilename).toEqual(join("..", "sourceMap", "[file].map"));
324329
});
325330

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

332337
expect(config.devtool).toEqual("hidden-source-map");
333338
expect(uglifyJsOptions.sourceMap).toBeTruthy();
339+
expect(uglifyJsOptions.terserOptions.output.semicolons).toBeFalsy();
334340
expect(config.output.sourceMapFilename).toEqual(join("..", newSourceMapFolder, "[file].map"));
335341
});
336342
});

Diff for: templates/webpack.javascript.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ module.exports = env => {
4545
hmr, // --env.hmr,
4646
unitTesting, // --env.unitTesting
4747
} = env;
48-
const externals = nsWebpack.getConvertedExternals(env.externals);
4948

49+
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
50+
const externals = nsWebpack.getConvertedExternals(env.externals);
5051
const appFullPath = resolve(projectRoot, appPath);
5152
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
5253

@@ -129,10 +130,11 @@ module.exports = env => {
129130
new TerserPlugin({
130131
parallel: true,
131132
cache: true,
132-
sourceMap: !!sourceMap || !!hiddenSourceMap,
133+
sourceMap: isAnySourceMapEnabled,
133134
terserOptions: {
134135
output: {
135136
comments: false,
137+
semicolons: !isAnySourceMapEnabled
136138
},
137139
compress: {
138140
// The Android SBG has problems parsing the output

Diff for: templates/webpack.typescript.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = env => {
4545
hmr, // --env.hmr,
4646
unitTesting, // --env.unitTesting
4747
} = env;
48+
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
4849
const externals = nsWebpack.getConvertedExternals(env.externals);
4950

5051
const appFullPath = resolve(projectRoot, appPath);
@@ -131,10 +132,11 @@ module.exports = env => {
131132
new TerserPlugin({
132133
parallel: true,
133134
cache: true,
134-
sourceMap: !!sourceMap || !!hiddenSourceMap,
135+
sourceMap: isAnySourceMapEnabled,
135136
terserOptions: {
136137
output: {
137138
comments: false,
139+
semicolons: !isAnySourceMapEnabled
138140
},
139141
compress: {
140142
// The Android SBG has problems parsing the output
@@ -207,7 +209,7 @@ module.exports = env => {
207209
configFile: "tsconfig.tns.json",
208210
allowTsInNodeModules: true,
209211
compilerOptions: {
210-
sourceMap
212+
isAnySourceMapEnabled
211213
}
212214
},
213215
}

Diff for: templates/webpack.vue.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module.exports = env => {
5050
unitTesting, // --env.unitTesting
5151
} = env;
5252

53+
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
5354
const externals = nsWebpack.getConvertedExternals(env.externals);
5455

5556
const mode = production ? "production" : "development"
@@ -142,10 +143,11 @@ module.exports = env => {
142143
new TerserPlugin({
143144
parallel: true,
144145
cache: true,
145-
sourceMap: !!sourceMap || !!hiddenSourceMap,
146+
sourceMap: isAnySourceMapEnabled,
146147
terserOptions: {
147148
output: {
148149
comments: false,
150+
semicolons: !isAnySourceMapEnabled
149151
},
150152
compress: {
151153
// The Android SBG has problems parsing the output

0 commit comments

Comments
 (0)