Skip to content

Commit 0224d2b

Browse files
alan-agius4vikerman
authored andcommitted
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
1 parent fc1fda2 commit 0224d2b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function getSourceMapDevTool(
9595
return new SourceMapDevToolPlugin({
9696
filename: inlineSourceMap ? undefined : '[file].map',
9797
include,
98-
moduleFilenameTemplate: '[namespace]/[resource-path]',
98+
moduleFilenameTemplate: '[resource-path]',
9999
append: hiddenSourceMap ? false : undefined,
100100
});
101101
}

packages/angular_devkit/build_angular/test/browser/source-map_spec_large.ts

+17
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,23 @@ describe('Browser Builder source map', () => {
3636
expect(await files['styles.css.map']).not.toBeUndefined();
3737
});
3838

39+
it(`sourcemaps sources should not start with '/'`, async () => {
40+
// If sourcemaps sources start with a '/' it will break VS code breakpoints
41+
// Unless 'sourceMapPathOverrides' are provided
42+
const overrides = {
43+
sourceMap: true,
44+
};
45+
46+
const { files } = await browserBuild(architect, host, target, overrides);
47+
const mainJSMap = await files['main.js.map'];
48+
expect(mainJSMap).not.toBeUndefined();
49+
50+
const sources: string[] = JSON.parse(mainJSMap).sources;
51+
for (const source of sources) {
52+
expect(source.startsWith('/')).toBe(false, `${source} started with an '/'.`);
53+
}
54+
});
55+
3956
it('works with outputHashing', async () => {
4057
const { files } = await browserBuild(architect, host, target, {
4158
sourceMap: true,

0 commit comments

Comments
 (0)