@@ -64,7 +64,7 @@ describe('@ngtools/webpack transformers', () => {
64
64
expect ( warningCalled ) . toBeTruthy ( ) ;
65
65
} ) ;
66
66
67
- it ( 'should support resolving reexports ' , ( ) => {
67
+ it ( 'should support resolving * re-exports ' , ( ) => {
68
68
const additionalFiles : Record < string , string > = {
69
69
'shared/index.ts' : `
70
70
export * from './path/to/lazy/lazy.module';
@@ -95,5 +95,79 @@ describe('@ngtools/webpack transformers', () => {
95
95
96
96
expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
97
97
} ) ;
98
+
99
+ it ( 'should support resolving named re-exports' , ( ) => {
100
+ const additionalFiles : Record < string , string > = {
101
+ 'shared/index.ts' : `
102
+ export { LazyModule } from './path/to/lazy/lazy.module';
103
+ ` ,
104
+ 'shared/path/to/lazy/lazy.module.ts' : `
105
+ export const LazyModule = {};
106
+ ` ,
107
+ } ;
108
+ const input = tags . stripIndent `
109
+ const ɵ0 = () => import('./shared').then(m => m.LazyModule);
110
+ const routes = [{
111
+ path: 'lazy',
112
+ loadChildren: ɵ0
113
+ }];
114
+ ` ;
115
+
116
+ const output = tags . stripIndent `
117
+ const ɵ0 = () => import("./shared/path/to/lazy/lazy.module.ngfactory").then(m => m.LazyModuleNgFactory);
118
+ const routes = [{
119
+ path: 'lazy',
120
+ loadChildren: ɵ0
121
+ }];
122
+ ` ;
123
+
124
+ const { program, compilerHost } = createTypescriptContext ( input , additionalFiles , true ) ;
125
+ const transformer = importFactory ( ( ) => { } , ( ) => program . getTypeChecker ( ) ) ;
126
+ const result = transformTypescript ( undefined , [ transformer ] , program , compilerHost ) ;
127
+
128
+ expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
129
+ } ) ;
130
+
131
+
132
+ it ( 'should support resolving re-export chains' , ( ) => {
133
+ const additionalFiles : Record < string , string > = {
134
+ 'shared/index.ts' : `
135
+ export { LazyModule } from './index2';
136
+ ` ,
137
+ 'shared/index2.ts' : `
138
+ export * from './index3';
139
+ ` ,
140
+ 'shared/index3.ts' : `
141
+ export { LazyModule } from './index4';
142
+ ` ,
143
+ 'shared/index4.ts' : `
144
+ export * from './path/to/lazy/lazy.module';
145
+ ` ,
146
+ 'shared/path/to/lazy/lazy.module.ts' : `
147
+ export const LazyModule = {};
148
+ ` ,
149
+ } ;
150
+ const input = tags . stripIndent `
151
+ const ɵ0 = () => import('./shared').then(m => m.LazyModule);
152
+ const routes = [{
153
+ path: 'lazy',
154
+ loadChildren: ɵ0
155
+ }];
156
+ ` ;
157
+
158
+ const output = tags . stripIndent `
159
+ const ɵ0 = () => import("./shared/path/to/lazy/lazy.module.ngfactory").then(m => m.LazyModuleNgFactory);
160
+ const routes = [{
161
+ path: 'lazy',
162
+ loadChildren: ɵ0
163
+ }];
164
+ ` ;
165
+
166
+ const { program, compilerHost } = createTypescriptContext ( input , additionalFiles , true ) ;
167
+ const transformer = importFactory ( ( ) => { } , ( ) => program . getTypeChecker ( ) ) ;
168
+ const result = transformTypescript ( undefined , [ transformer ] , program , compilerHost ) ;
169
+
170
+ expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
171
+ } ) ;
98
172
} ) ;
99
173
} ) ;
0 commit comments