Skip to content

Commit 2e1c966

Browse files
filipesilvahansl
authored andcommitted
fix(@angular/cli): fix eval-sourcemap when sourcemap is undefined
Also add test to ensure it doesn't break. Followup to #7919
1 parent 97c4873 commit 2e1c966

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

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 => {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {execAndWaitForOutputToMatch, killAllProcesses} from '../../utils/process';
2+
import {getGlobalVariable} from '../../utils/env';
3+
4+
5+
export default function() {
6+
// Skip this in ejected tests.
7+
if (getGlobalVariable('argv').eject) {
8+
return Promise.resolve();
9+
}
10+
11+
return Promise.resolve()
12+
// Check that ng serve has eval sourcemaps by default.
13+
.then(() => execAndWaitForOutputToMatch('ng', ['serve'], /webpack: Compiled successfully/))
14+
.then((output) => {
15+
const stdout = output.stdout;
16+
if (/\.js\.map/.test(stdout)) {
17+
throw new Error('Expected eval sourcemap but file sourcemap was present instead.');
18+
}
19+
})
20+
.then(() => killAllProcesses(), (err: any) => {
21+
killAllProcesses();
22+
throw err;
23+
});
24+
}

0 commit comments

Comments
 (0)