@@ -22,25 +22,6 @@ export function testScrubFile(content: string) {
2222 return markers . some ( ( marker ) => content . indexOf ( marker ) !== - 1 ) ;
2323}
2424
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-
4425export function getScrubFileTransformer ( program : ts . Program ) : ts . TransformerFactory < ts . SourceFile > {
4526 return scrubFileTransformer ( program . getTypeChecker ( ) , false ) ;
4627}
@@ -111,33 +92,18 @@ export function expect<T extends ts.Node>(node: ts.Node, kind: ts.SyntaxKind): T
11192 return node as T ;
11293}
11394
114- function nameOfSpecifier ( node : ts . ImportSpecifier ) : string {
115- return node . name && node . name . text || '<unknown>' ;
116- }
117-
11895function findAngularMetadata ( node : ts . Node , isAngularCoreFile : boolean ) : ts . Node [ ] {
119- let specs : ts . Node [ ] = [ ] ;
96+ const specs : ts . Node [ ] = [ ] ;
12097 // Find all specifiers from imports of `@angular/core`.
12198 ts . forEachChild ( node , ( child ) => {
12299 if ( child . kind === ts . SyntaxKind . ImportDeclaration ) {
123100 const importDecl = child as ts . ImportDeclaration ;
124101 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 ) ) ;
127103 }
128104 }
129105 } ) ;
130106
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-
141107 return specs ;
142108}
143109
@@ -177,10 +143,6 @@ function isAngularCoreImport(node: ts.ImportDeclaration, isAngularCoreFile: bool
177143 return false ;
178144}
179145
180- function isAngularCoreSpecifier ( node : ts . ImportSpecifier ) : boolean {
181- return angularSpecifiers . indexOf ( nameOfSpecifier ( node ) ) !== - 1 ;
182- }
183-
184146// Check if assignment is `Clazz.decorators = [...];`.
185147function isDecoratorAssignmentExpression ( exprStmt : ts . ExpressionStatement ) : boolean {
186148 if ( exprStmt . expression . kind !== ts . SyntaxKind . BinaryExpression ) {
@@ -390,7 +352,6 @@ function pickDecorateNodesToRemove(
390352) : ts . Node [ ] {
391353
392354 const expr = expect < ts . BinaryExpression > ( exprStmt . expression , ts . SyntaxKind . BinaryExpression ) ;
393- const classId = expect < ts . Identifier > ( expr . left , ts . SyntaxKind . Identifier ) ;
394355 let callExpr : ts . CallExpression ;
395356
396357 if ( expr . right . kind === ts . SyntaxKind . CallExpression ) {
0 commit comments