6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import remapping from '@ampproject/remapping' ;
10
9
import { custom } from 'babel-loader' ;
11
10
import { ScriptTarget } from 'typescript' ;
12
11
import { loadEsmModule } from '../utils/load-esm' ;
@@ -23,9 +22,6 @@ interface AngularCustomOptions extends Omit<ApplicationPresetOptions, 'instrumen
23
22
24
23
export type AngularBabelLoaderOptions = AngularCustomOptions & Record < string , unknown > ;
25
24
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
-
29
25
/**
30
26
* Cached instance of the compiler-cli linker's needsLinking function.
31
27
*/
@@ -218,7 +214,7 @@ export default custom<ApplicationPresetOptions>(() => {
218
214
// Using `false` disables babel from attempting to locate sourcemaps or process any inline maps.
219
215
// The babel types do not include the false option even though it is valid
220
216
// eslint-disable-next-line @typescript-eslint/no-explicit-any
221
- inputSourceMap : false as any ,
217
+ inputSourceMap : configuration . options . inputSourceMap ?? ( false as any ) ,
222
218
presets : [
223
219
...( configuration . options . presets || [ ] ) ,
224
220
[
@@ -242,26 +238,5 @@ export default custom<ApplicationPresetOptions>(() => {
242
238
] ,
243
239
} ;
244
240
} ,
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
- } ,
266
241
} ;
267
242
} ) ;
0 commit comments