Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): fix sourcemaps for vscode breakpo…
Browse files Browse the repository at this point in the history
…ints

`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
  • Loading branch information
alan-agius4 authored and vikerman committed Jul 25, 2019
1 parent fc1fda2 commit 0224d2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0224d2b

Please sign in to comment.