diff --git a/packages/angular_devkit/build_angular/src/babel/webpack-loader.ts b/packages/angular_devkit/build_angular/src/babel/webpack-loader.ts index 3653ab20c4fc..abe66ea9967b 100644 --- a/packages/angular_devkit/build_angular/src/babel/webpack-loader.ts +++ b/packages/angular_devkit/build_angular/src/babel/webpack-loader.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import remapping from '@ampproject/remapping'; import { custom } from 'babel-loader'; import { ScriptTarget } from 'typescript'; import { loadEsmModule } from '../utils/load-esm'; @@ -23,9 +22,6 @@ interface AngularCustomOptions extends Omit; -// Extract Sourcemap input type from the remapping function since it is not currently exported -type SourceMapInput = Exclude[0], unknown[]>; - /** * Cached instance of the compiler-cli linker's needsLinking function. */ @@ -218,7 +214,7 @@ export default custom(() => { // Using `false` disables babel from attempting to locate sourcemaps or process any inline maps. // The babel types do not include the false option even though it is valid // eslint-disable-next-line @typescript-eslint/no-explicit-any - inputSourceMap: false as any, + inputSourceMap: configuration.options.inputSourceMap ?? (false as any), presets: [ ...(configuration.options.presets || []), [ @@ -242,26 +238,5 @@ export default custom(() => { ], }; }, - result(result, { map: inputSourceMap }) { - if (result.map && inputSourceMap) { - // Merge the intermediate sourcemap generated by babel with the input source map. - // The casting is required due to slight differences in the types for babel and - // `@ampproject/remapping` source map objects but both are compatible with Webpack. - // This method for merging is used because it provides more accurate output - // and is faster while using less memory. - result.map = { - // Convert the SourceMap back to simple plain object. - // This is needed because otherwise code-coverage will fail with `don't know how to turn this value into a node` - // Which is thrown by Babel if it is invoked again from `istanbul-lib-instrument`. - // https://github.com/babel/babel/blob/780aa48d2a34dc55f556843074b6aed45e7eabeb/packages/babel-types/src/converters/valueToNode.ts#L115-L130 - ...(remapping( - [result.map as SourceMapInput, inputSourceMap as SourceMapInput], - () => null, - ) as typeof result.map), - }; - } - - return result; - }, }; });