Skip to content

Commit 5805c78

Browse files
divdavemalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): transform remapped sourcemap into a plain object
`remapping` returns a SourceMap object and not a plain object. This causes Babel to fail with `don't know how to turn this value into a node` when invoked from `istanbul-lib-instrument` as Babel checks if the value is a plain object. See: https://github.com/babel/babel/blob/780aa48d2a34dc55f556843074b6aed45e7eabeb/packages/babel-types/src/converters/valueToNode.ts#L115-L130 This was previously fixed in commit da1733c but the fix was lost as part of commit 0c44ab3.
1 parent 3c681b6 commit 5805c78

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/angular_devkit/build_angular/src/babel/webpack-loader.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,16 @@ export default custom<ApplicationPresetOptions>(() => {
239239
// `@ampproject/remapping` source map objects but both are compatible with Webpack.
240240
// This method for merging is used because it provides more accurate output
241241
// and is faster while using less memory.
242-
result.map = remapping(
243-
[result.map as SourceMapInput, inputSourceMap as SourceMapInput],
244-
() => null,
245-
) as typeof result.map;
242+
result.map = {
243+
// Convert the SourceMap back to simple plain object.
244+
// This is needed because otherwise code-coverage will fail with `don't know how to turn this value into a node`
245+
// Which is thrown by Babel if it is invoked again from `istanbul-lib-instrument`.
246+
// https://github.com/babel/babel/blob/780aa48d2a34dc55f556843074b6aed45e7eabeb/packages/babel-types/src/converters/valueToNode.ts#L115-L130
247+
...(remapping(
248+
[result.map as SourceMapInput, inputSourceMap as SourceMapInput],
249+
() => null,
250+
) as typeof result.map),
251+
};
246252
}
247253

248254
return result;

0 commit comments

Comments
 (0)