@@ -33,6 +33,19 @@ describe('@ngtools/webpack transformers', () => {
33
33
` ,
34
34
} ;
35
35
36
+ it ( 'should remove unused imports' , ( ) => {
37
+ const input = tags . stripIndent `
38
+ import { promise } from './const';
39
+ import { take } from './const';
40
+ const unused = promise;
41
+ ` ;
42
+
43
+ const { program, compilerHost } = createTypescriptContext ( input , additionalFiles ) ;
44
+ const result = transformTypescript ( undefined , [ transformer ( program ) ] , program , compilerHost ) ;
45
+
46
+ expect ( tags . oneLine `${ result } ` ) . toEqual ( '' ) ;
47
+ } ) ;
48
+
36
49
it ( 'should remove unused aliased imports' , ( ) => {
37
50
const input = tags . stripIndent `
38
51
import { promise as fromPromise } from './const';
@@ -188,7 +201,7 @@ describe('@ngtools/webpack transformers', () => {
188
201
expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
189
202
} ) ;
190
203
191
- it ( 'should only drop unused default imports when named and default' , ( ) => {
204
+ it ( 'should only drop unused default imports when named and default (1) ' , ( ) => {
192
205
const input = tags . stripIndent `
193
206
import promise, { promise as fromPromise } from './const';
194
207
const used = fromPromise;
@@ -206,7 +219,7 @@ describe('@ngtools/webpack transformers', () => {
206
219
expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
207
220
} ) ;
208
221
209
- it ( 'should only drop unused named imports when named and default' , ( ) => {
222
+ it ( 'should only drop unused named imports when named and default (2) ' , ( ) => {
210
223
const input = tags . stripIndent `
211
224
import promise, { promise as fromPromise, take } from './const';
212
225
const used = fromPromise;
@@ -224,7 +237,7 @@ describe('@ngtools/webpack transformers', () => {
224
237
expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
225
238
} ) ;
226
239
227
- it ( 'should only drop default imports when having named and default' , ( ) => {
240
+ it ( 'should only drop default imports when having named and default (3) ' , ( ) => {
228
241
const input = tags . stripIndent `
229
242
import promise, { fromPromise } from './const';
230
243
const used = promise;
0 commit comments