From 70a51039f55a905e9a8a301796e28007b9123e23 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Mon, 9 Oct 2017 17:26:44 +0100 Subject: [PATCH] fix(@angular/cli): fix eval-sourcemap when sourcemap is undefined Also add test to ensure it doesn't break. Followup to #7919 --- packages/@angular/cli/commands/serve.ts | 7 ++----- tests/e2e/tests/build/eval-sourcemap.ts | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 tests/e2e/tests/build/eval-sourcemap.ts diff --git a/packages/@angular/cli/commands/serve.ts b/packages/@angular/cli/commands/serve.ts index 1550ff0d644e..384f6ef0542a 100644 --- a/packages/@angular/cli/commands/serve.ts +++ b/packages/@angular/cli/commands/serve.ts @@ -135,11 +135,8 @@ const ServeCommand = Command.extend({ commandOptions.vendorChunk = !commandOptions.buildOptimizer; } - // Default evalSourcemaps to true when sourcemaps are true. - // This makes rebuilds faster. - if (commandOptions.sourcemaps === true) { - commandOptions.evalSourcemaps = true; - } + // Default evalSourcemaps to true for serve. This makes rebuilds faster. + commandOptions.evalSourcemaps = true; return checkPort(commandOptions.port, commandOptions.host, defaultPort) .then(port => { diff --git a/tests/e2e/tests/build/eval-sourcemap.ts b/tests/e2e/tests/build/eval-sourcemap.ts new file mode 100644 index 000000000000..0d3db0e06d8a --- /dev/null +++ b/tests/e2e/tests/build/eval-sourcemap.ts @@ -0,0 +1,24 @@ +import {execAndWaitForOutputToMatch, killAllProcesses} from '../../utils/process'; +import {getGlobalVariable} from '../../utils/env'; + + +export default function() { + // Skip this in ejected tests. + if (getGlobalVariable('argv').eject) { + return Promise.resolve(); + } + + return Promise.resolve() + // Check that ng serve has eval sourcemaps by default. + .then(() => execAndWaitForOutputToMatch('ng', ['serve'], /webpack: Compiled successfully/)) + .then((output) => { + const stdout = output.stdout; + if (/\.js\.map/.test(stdout)) { + throw new Error('Expected eval sourcemap but file sourcemap was present instead.'); + } + }) + .then(() => killAllProcesses(), (err: any) => { + killAllProcesses(); + throw err; + }); +}