Skip to content

Commit 2aa6f57

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
1 parent f227e14 commit 2aa6f57

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,20 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
284284
if (scriptsSourceMap || stylesSourceMap) {
285285
extraRules.push({
286286
test: /\.m?js$/,
287-
exclude: vendorSourceMap ? undefined : /[\\\/]node_modules[\\\/]/,
288287
enforce: 'pre',
289288
loader: require.resolve('source-map-loader'),
289+
options: {
290+
filterSourceMappingUrl: (_mapUri: string, resourcePath: string) => {
291+
if (vendorSourceMap) {
292+
// Consume all sourcemaps when vendor option is enabled.
293+
return true;
294+
}
295+
296+
// Don't consume sourcemaps in node_modules when vendor is disabled.
297+
// But, do consume local libraries sourcemaps.
298+
return !resourcePath.includes('node_modules');
299+
},
300+
},
290301
});
291302
}
292303

0 commit comments

Comments
 (0)