Skip to content

Commit 82e56cc

Browse files
committed
fix(@angular/cli): fix eval-sourcemap when sourcemap is undefined
Also add test to ensure it doesn't break. Followup to #7919
1 parent eed13cf commit 82e56cc

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

packages/@angular/cli/commands/serve.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,8 @@ const ServeCommand = Command.extend({
135135
commandOptions.vendorChunk = !commandOptions.buildOptimizer;
136136
}
137137

138-
// Default evalSourcemaps to true when sourcemaps are true.
139-
// This makes rebuilds faster.
140-
if (commandOptions.sourcemaps === true) {
141-
commandOptions.evalSourcemaps = true;
142-
}
138+
// Default evalSourcemaps to true for serve. This makes rebuilds faster.
139+
commandOptions.evalSourcemaps = true;
143140

144141
return checkPort(commandOptions.port, commandOptions.host, defaultPort)
145142
.then(port => {

tests/e2e/tests/build/sourcemap.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ng} from '../../utils/process';
1+
import {ng, execAndWaitForOutputToMatch} from '../../utils/process';
22
import {expectFileToExist} from '../../utils/fs';
33
import {expectToFail} from '../../utils/utils';
44
import {getGlobalVariable} from '../../utils/env';
@@ -20,5 +20,15 @@ export default function() {
2020
.then(() => expectToFail(() => expectFileToExist('dist/main.bundle.js.map')))
2121

2222
.then(() => ng('build', '--prod', '--output-hashing=none', '--sourcemap'))
23-
.then(() => expectFileToExist('dist/main.bundle.js.map'));
23+
.then(() => expectFileToExist('dist/main.bundle.js.map'))
24+
25+
// Check that ng serve has eval sourcemaps by default.
26+
.then(() => execAndWaitForOutputToMatch('ng', ['serve'], /webpack: Compiled successfully/))
27+
.then((output) => {
28+
const stdout = output.stdout;
29+
if (/\.js\.map/.test(stdout)) {
30+
throw new Error('Expected eval sourcemap but file sourcemap was present instead.');
31+
}
32+
})
33+
;
2434
}

0 commit comments

Comments
 (0)