9
9
import { custom } from 'babel-loader' ;
10
10
import { loadEsmModule } from '../../utils/load-esm' ;
11
11
import { VERSION } from '../../utils/package-version' ;
12
- import { ApplicationPresetOptions , I18nPluginCreators } from './presets/application' ;
12
+ import {
13
+ ApplicationPresetOptions ,
14
+ I18nPluginCreators ,
15
+ requiresLinking ,
16
+ } from './presets/application' ;
13
17
14
18
interface AngularCustomOptions extends Omit < ApplicationPresetOptions , 'instrumentCode' > {
15
19
instrumentCode ?: {
@@ -21,11 +25,6 @@ interface AngularCustomOptions extends Omit<ApplicationPresetOptions, 'instrumen
21
25
22
26
export type AngularBabelLoaderOptions = AngularCustomOptions & Record < string , unknown > ;
23
27
24
- /**
25
- * Cached instance of the compiler-cli linker's needsLinking function.
26
- */
27
- let needsLinking : typeof import ( '@angular/compiler-cli/linker' ) . needsLinking | undefined ;
28
-
29
28
/**
30
29
* Cached instance of the compiler-cli linker's Babel plugin factory function.
31
30
*/
@@ -38,26 +37,6 @@ let linkerPluginCreator:
38
37
*/
39
38
let i18nPluginCreators : I18nPluginCreators | undefined ;
40
39
41
- export async function requiresLinking ( path : string , source : string ) : Promise < boolean > {
42
- // @angular /core and @angular /compiler will cause false positives
43
- // Also, TypeScript files do not require linking
44
- if ( / [ \\ / ] @ a n g u l a r [ \\ / ] (?: c o m p i l e r | c o r e ) | \. t s x ? $ / . test ( path ) ) {
45
- return false ;
46
- }
47
-
48
- if ( ! needsLinking ) {
49
- // Load ESM `@angular/compiler-cli/linker` using the TypeScript dynamic import workaround.
50
- // Once TypeScript provides support for keeping the dynamic import this workaround can be
51
- // changed to a direct dynamic import.
52
- const linkerModule = await loadEsmModule < typeof import ( '@angular/compiler-cli/linker' ) > (
53
- '@angular/compiler-cli/linker' ,
54
- ) ;
55
- needsLinking = linkerModule . needsLinking ;
56
- }
57
-
58
- return needsLinking ( path , source ) ;
59
- }
60
-
61
40
// eslint-disable-next-line max-lines-per-function
62
41
export default custom < ApplicationPresetOptions > ( ( ) => {
63
42
const baseOptions = Object . freeze ( {
0 commit comments