66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import remapping from '@ampproject/remapping' ;
109import { custom } from 'babel-loader' ;
1110import { ScriptTarget } from 'typescript' ;
1211import { loadEsmModule } from '../utils/load-esm' ;
@@ -23,9 +22,6 @@ interface AngularCustomOptions extends Omit<ApplicationPresetOptions, 'instrumen
2322
2423export type AngularBabelLoaderOptions = AngularCustomOptions & Record < string , unknown > ;
2524
26- // Extract Sourcemap input type from the remapping function since it is not currently exported
27- type SourceMapInput = Exclude < Parameters < typeof remapping > [ 0 ] , unknown [ ] > ;
28-
2925/**
3026 * Cached instance of the compiler-cli linker's needsLinking function.
3127 */
@@ -218,7 +214,7 @@ export default custom<ApplicationPresetOptions>(() => {
218214 // Using `false` disables babel from attempting to locate sourcemaps or process any inline maps.
219215 // The babel types do not include the false option even though it is valid
220216 // eslint-disable-next-line @typescript-eslint/no-explicit-any
221- inputSourceMap : false as any ,
217+ inputSourceMap : configuration . options . inputSourceMap ?? ( false as any ) ,
222218 presets : [
223219 ...( configuration . options . presets || [ ] ) ,
224220 [
@@ -242,26 +238,5 @@ export default custom<ApplicationPresetOptions>(() => {
242238 ] ,
243239 } ;
244240 } ,
245- result ( result , { map : inputSourceMap } ) {
246- if ( result . map && inputSourceMap ) {
247- // Merge the intermediate sourcemap generated by babel with the input source map.
248- // The casting is required due to slight differences in the types for babel and
249- // `@ampproject/remapping` source map objects but both are compatible with Webpack.
250- // This method for merging is used because it provides more accurate output
251- // and is faster while using less memory.
252- result . map = {
253- // Convert the SourceMap back to simple plain object.
254- // This is needed because otherwise code-coverage will fail with `don't know how to turn this value into a node`
255- // Which is thrown by Babel if it is invoked again from `istanbul-lib-instrument`.
256- // https://github.com/babel/babel/blob/780aa48d2a34dc55f556843074b6aed45e7eabeb/packages/babel-types/src/converters/valueToNode.ts#L115-L130
257- ...( remapping (
258- [ result . map as SourceMapInput , inputSourceMap as SourceMapInput ] ,
259- ( ) => null ,
260- ) as typeof result . map ) ,
261- } ;
262- }
263-
264- return result ;
265- } ,
266241 } ;
267242} ) ;
0 commit comments