Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): do not consume inline sourcemaps …
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
alan-agius4 committed Aug 6, 2021
1 parent 8dc3c89 commit cea0280
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,20 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
if (scriptsSourceMap || stylesSourceMap) {
extraRules.push({
test: /\.m?js$/,
exclude: vendorSourceMap ? undefined : /[\\\/]node_modules[\\\/]/,
enforce: 'pre',
loader: require.resolve('source-map-loader'),
options: {
filterSourceMappingUrl: (_mapUri: string, resourcePath: string) => {
if (vendorSourceMap) {
// Consume all sourcemaps when vendor option is enabled.
return true;
}

// Don't consume sourcemaps in node_modules when vendor is disabled.
// But, do consume local libraries sourcemaps.
return !resourcePath.includes('node_modules');
},
},
});
}

Expand Down

0 comments on commit cea0280

Please sign in to comment.