@@ -22,25 +22,6 @@ export function testScrubFile(content: string) {
22
22
return markers . some ( ( marker ) => content . indexOf ( marker ) !== - 1 ) ;
23
23
}
24
24
25
- const angularSpecifiers = [
26
- // Class level decorators.
27
- 'Component' ,
28
- 'Directive' ,
29
- 'Injectable' ,
30
- 'NgModule' ,
31
- 'Pipe' ,
32
-
33
- // Property level decorators.
34
- 'ContentChild' ,
35
- 'ContentChildren' ,
36
- 'HostBinding' ,
37
- 'HostListener' ,
38
- 'Input' ,
39
- 'Output' ,
40
- 'ViewChild' ,
41
- 'ViewChildren' ,
42
- ] ;
43
-
44
25
export function getScrubFileTransformer ( program : ts . Program ) : ts . TransformerFactory < ts . SourceFile > {
45
26
return scrubFileTransformer ( program . getTypeChecker ( ) , false ) ;
46
27
}
@@ -111,33 +92,18 @@ export function expect<T extends ts.Node>(node: ts.Node, kind: ts.SyntaxKind): T
111
92
return node as T ;
112
93
}
113
94
114
- function nameOfSpecifier ( node : ts . ImportSpecifier ) : string {
115
- return node . name && node . name . text || '<unknown>' ;
116
- }
117
-
118
95
function findAngularMetadata ( node : ts . Node , isAngularCoreFile : boolean ) : ts . Node [ ] {
119
- let specs : ts . Node [ ] = [ ] ;
96
+ const specs : ts . Node [ ] = [ ] ;
120
97
// Find all specifiers from imports of `@angular/core`.
121
98
ts . forEachChild ( node , ( child ) => {
122
99
if ( child . kind === ts . SyntaxKind . ImportDeclaration ) {
123
100
const importDecl = child as ts . ImportDeclaration ;
124
101
if ( isAngularCoreImport ( importDecl , isAngularCoreFile ) ) {
125
- specs . push ( ...collectDeepNodes < ts . ImportSpecifier > ( node , ts . SyntaxKind . ImportSpecifier )
126
- . filter ( ( spec ) => isAngularCoreSpecifier ( spec ) ) ) ;
102
+ specs . push ( ...collectDeepNodes < ts . ImportSpecifier > ( importDecl , ts . SyntaxKind . ImportSpecifier ) ) ;
127
103
}
128
104
}
129
105
} ) ;
130
106
131
- // Check if the current module contains all know `@angular/core` specifiers.
132
- // If it does, we assume it's a `@angular/core` FESM.
133
- if ( isAngularCoreFile ) {
134
- const localDecl = findAllDeclarations ( node )
135
- . filter ( ( decl ) => angularSpecifiers . indexOf ( ( decl . name as ts . Identifier ) . text ) !== - 1 ) ;
136
- if ( localDecl . length === angularSpecifiers . length ) {
137
- specs = specs . concat ( localDecl ) ;
138
- }
139
- }
140
-
141
107
return specs ;
142
108
}
143
109
@@ -177,10 +143,6 @@ function isAngularCoreImport(node: ts.ImportDeclaration, isAngularCoreFile: bool
177
143
return false ;
178
144
}
179
145
180
- function isAngularCoreSpecifier ( node : ts . ImportSpecifier ) : boolean {
181
- return angularSpecifiers . indexOf ( nameOfSpecifier ( node ) ) !== - 1 ;
182
- }
183
-
184
146
// Check if assignment is `Clazz.decorators = [...];`.
185
147
function isDecoratorAssignmentExpression ( exprStmt : ts . ExpressionStatement ) : boolean {
186
148
if ( exprStmt . expression . kind !== ts . SyntaxKind . BinaryExpression ) {
@@ -390,7 +352,6 @@ function pickDecorateNodesToRemove(
390
352
) : ts . Node [ ] {
391
353
392
354
const expr = expect < ts . BinaryExpression > ( exprStmt . expression , ts . SyntaxKind . BinaryExpression ) ;
393
- const classId = expect < ts . Identifier > ( expr . left , ts . SyntaxKind . Identifier ) ;
394
355
let callExpr : ts . CallExpression ;
395
356
396
357
if ( expr . right . kind === ts . SyntaxKind . CallExpression ) {
0 commit comments