mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 19:13:34 +08:00
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:
parent
fc1fda2663
commit
0224d2b92e
@ -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,
|
||||
});
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user