fix(@angular-devkit/build-angular): fix sourcemaps for vscode breakpoints

`namespace` is always empty which is breaking sourcemaps since when sources start with `/` vscode will not be able to resolve them unless users configure `sourceMapPathOverrides`.

Fixes #15116
This commit is contained in:
Alan 2019-07-19 15:16:45 +02:00 committed by vikerman
parent fc1fda2663
commit 0224d2b92e
2 changed files with 18 additions and 1 deletions

View File

@ -95,7 +95,7 @@ export function getSourceMapDevTool(
return new SourceMapDevToolPlugin({
filename: inlineSourceMap ? undefined : '[file].map',
include,
moduleFilenameTemplate: '[namespace]/[resource-path]',
moduleFilenameTemplate: '[resource-path]',
append: hiddenSourceMap ? false : undefined,
});
}

View File

@ -36,6 +36,23 @@ describe('Browser Builder source map', () => {
expect(await files['styles.css.map']).not.toBeUndefined();
});
it(`sourcemaps sources should not start with '/'`, async () => {
// If sourcemaps sources start with a '/' it will break VS code breakpoints
// Unless 'sourceMapPathOverrides' are provided
const overrides = {
sourceMap: true,
};
const { files } = await browserBuild(architect, host, target, overrides);
const mainJSMap = await files['main.js.map'];
expect(mainJSMap).not.toBeUndefined();
const sources: string[] = JSON.parse(mainJSMap).sources;
for (const source of sources) {
expect(source.startsWith('/')).toBe(false, `${source} started with an '/'.`);
}
});
it('works with outputHashing', async () => {
const { files } = await browserBuild(architect, host, target, {
sourceMap: true,