Skip to content

Commit cea0280

Browse files
committed
fix(@angular-devkit/build-angular): do not consume inline sourcemaps when vendor sourcemaps is disabled.
Not removing inline sourcemaps when vendor sourcemaps is disabled causes an issue during the JS optimization sourcemap merging phase. ``` Optimization error [936.cf7797927c7f989bd40d.js]: Error: Transformation map 1 must have exactly one source file. ``` When vendor sourcemaps is disabled we are not interested into the said sourcemaps so now we remove the inline sourcemap. Closes #21508 (cherry picked from commit 2aa6f57)
1 parent 8dc3c89 commit cea0280

File tree

1 file changed

+12
-1
lines changed
  • packages/angular_devkit/build_angular/src/webpack/configs

1 file changed

+12
-1
lines changed

packages/angular_devkit/build_angular/src/webpack/configs/common.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,20 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
314314
if (scriptsSourceMap || stylesSourceMap) {
315315
extraRules.push({
316316
test: /\.m?js$/,
317-
exclude: vendorSourceMap ? undefined : /[\\\/]node_modules[\\\/]/,
318317
enforce: 'pre',
319318
loader: require.resolve('source-map-loader'),
319+
options: {
320+
filterSourceMappingUrl: (_mapUri: string, resourcePath: string) => {
321+
if (vendorSourceMap) {
322+
// Consume all sourcemaps when vendor option is enabled.
323+
return true;
324+
}
325+
326+
// Don't consume sourcemaps in node_modules when vendor is disabled.
327+
// But, do consume local libraries sourcemaps.
328+
return !resourcePath.includes('node_modules');
329+
},
330+
},
320331
});
321332
}
322333

0 commit comments

Comments
 (0)