Skip to content

Commit d4fa88b

Browse files
alan-agius4mgechev
authored andcommitted
fix(@angular-devkit/build-angular): account for hashed and non hashed filesnames when having sourcemaps
1 parent 6eb72e7 commit d4fa88b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/angular_devkit/build_angular/src/utils/action-cache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export class BundleActionCache {
5656

5757
// sourceMappingURL is added at the very end which causes the code to be the same when sourcemaps are enabled/disabled
5858
// When using hiddenSourceMaps we can omit the postfix since sourceMappingURL will not be added.
59-
const sourceMapPostFix = action.sourceMaps && !action.hiddenSourceMaps ? '|sourcemap' : '';
59+
// When having sourcemaps a hashed file and non hashed file can have the same content. But the sourceMappingURL will differ.
60+
const sourceMapPostFix = action.sourceMaps && !action.hiddenSourceMaps ? `|sourcemap|${action.filename}` : '';
6061

6162
const baseCacheKey = this.generateBaseCacheKey(action.code);
6263

tests/legacy-cli/e2e/tests/build/sourcemap.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { expectFileToExist } from '../../utils/fs';
33
import { ng } from '../../utils/process';
44

55
export default async function () {
6+
// The below is needed to cache bundles and verify that sourcemaps are generated
7+
// corretly when output-hashing is disabled.
8+
await ng('build', '--output-hashing=bundles', '--source-map');
9+
610
await ng('build', '--prod', '--output-hashing=none', '--source-map');
711
await testForSourceMaps(6);
812

0 commit comments

Comments
 (0)