@@ -16,7 +16,6 @@ import {
16
16
host ,
17
17
lazyModuleFiles ,
18
18
lazyModuleFnImport ,
19
- lazyModuleStringImport ,
20
19
veEnabled ,
21
20
} from '../../test-utils' ;
22
21
@@ -54,40 +53,30 @@ describe('Browser Builder lazy modules', () => {
54
53
logs . includes ( 'Module not found' ) ;
55
54
}
56
55
57
- const cases : [ string , Record < string , string > ] [ ] = [
58
- [ 'string' , lazyModuleStringImport ] ,
59
- [ 'function' , lazyModuleFnImport ] ,
60
- ] ;
61
- for ( const [ name , imports ] of cases ) {
62
- describe ( `Load children ${ name } syntax` , ( ) => {
63
- it ( 'supports lazy bundle for lazy routes with JIT' , async ( ) => {
64
- host . writeMultipleFiles ( lazyModuleFiles ) ;
65
- host . writeMultipleFiles ( imports ) ;
66
-
67
- if ( name === 'string' ) {
68
- addLazyLoadedModulesInTsConfig ( host , lazyModuleFiles ) ;
69
- }
70
-
71
- const { files } = await browserBuild ( architect , host , target ) ;
72
- expect ( 'lazy-lazy-module.js' in files ) . toBe ( true ) ;
73
- } ) ;
56
+ describe ( `Load children syntax` , ( ) => {
57
+ it ( 'supports lazy bundle for lazy routes with JIT' , async ( ) => {
58
+ host . writeMultipleFiles ( lazyModuleFiles ) ;
59
+ host . writeMultipleFiles ( lazyModuleFnImport ) ;
74
60
75
- it ( 'supports lazy bundle for lazy routes with AOT' , async ( ) => {
76
- host . writeMultipleFiles ( lazyModuleFiles ) ;
77
- host . writeMultipleFiles ( imports ) ;
78
- addLazyLoadedModulesInTsConfig ( host , lazyModuleFiles ) ;
61
+ const { files } = await browserBuild ( architect , host , target ) ;
62
+ expect ( 'lazy-lazy-module.js' in files ) . toBe ( true ) ;
63
+ } ) ;
79
64
80
- const { files } = await browserBuild ( architect , host , target , { aot : true } ) ;
81
- if ( ! veEnabled ) {
82
- const data = await files [ 'lazy-lazy-module.js' ] ;
83
- expect ( data ) . not . toBeUndefined ( 'Lazy module output bundle does not exist' ) ;
84
- expect ( data ) . toContain ( 'LazyModule.ɵmod' ) ;
85
- } else {
86
- expect ( files [ 'lazy-lazy-module-ngfactory.js' ] ) . not . toBeUndefined ( ) ;
87
- }
88
- } ) ;
65
+ it ( 'supports lazy bundle for lazy routes with AOT' , async ( ) => {
66
+ host . writeMultipleFiles ( lazyModuleFiles ) ;
67
+ host . writeMultipleFiles ( lazyModuleFnImport ) ;
68
+ addLazyLoadedModulesInTsConfig ( host , lazyModuleFiles ) ;
69
+
70
+ const { files } = await browserBuild ( architect , host , target , { aot : true } ) ;
71
+ if ( ! veEnabled ) {
72
+ const data = await files [ 'lazy-lazy-module.js' ] ;
73
+ expect ( data ) . not . toBeUndefined ( 'Lazy module output bundle does not exist' ) ;
74
+ expect ( data ) . toContain ( 'LazyModule.ɵmod' ) ;
75
+ } else {
76
+ expect ( files [ 'lazy-lazy-module-ngfactory.js' ] ) . not . toBeUndefined ( ) ;
77
+ }
89
78
} ) ;
90
- }
79
+ } ) ;
91
80
92
81
// Errors for missing lazy routes are only supported with function syntax.
93
82
// `ngProgram.listLazyRoutes` will ignore invalid lazy routes in the route map.
@@ -202,69 +191,4 @@ describe('Browser Builder lazy modules', () => {
202
191
expect ( files [ 'two.js' ] ) . not . toBeUndefined ( ) ;
203
192
expect ( files [ 'common.js' ] ) . toBeUndefined ( ) ;
204
193
} ) ;
205
-
206
- it ( `supports extra lazy modules array in JIT` , async ( ) => {
207
- host . writeMultipleFiles ( lazyModuleFiles ) ;
208
- host . writeMultipleFiles ( {
209
- 'src/app/app.component.ts' : `
210
- import { Component, SystemJsNgModuleLoader } from '@angular/core';
211
-
212
- @Component({
213
- selector: 'app-root',
214
- templateUrl: './app.component.html',
215
- styleUrls: ['./app.component.css'],
216
- })
217
- export class AppComponent {
218
- title = 'app';
219
- constructor(loader: SystemJsNgModuleLoader) {
220
- // Module will be split at build time and loaded when requested below
221
- loader.load('src/app/lazy/lazy.module#LazyModule')
222
- .then((factory) => { /* Use factory here */ });
223
- }
224
- }` ,
225
- } ) ;
226
- host . replaceInFile ( 'src/tsconfig.app.json' , `"module": "es2015"` , `"module": "esnext"` ) ;
227
- addLazyLoadedModulesInTsConfig ( host , lazyModuleFiles ) ;
228
-
229
- const { files } = await browserBuild ( architect , host , target , {
230
- lazyModules : [ 'src/app/lazy/lazy.module' ] ,
231
- } ) ;
232
- expect ( files [ 'src-app-lazy-lazy-module.js' ] ) . not . toBeUndefined ( ) ;
233
- } ) ;
234
-
235
- it ( `supports extra lazy modules array in AOT` , async ( ) => {
236
- host . writeMultipleFiles ( lazyModuleFiles ) ;
237
- host . writeMultipleFiles ( {
238
- 'src/app/app.component.ts' : `
239
- import { Component, SystemJsNgModuleLoader } from '@angular/core';
240
-
241
- @Component({
242
- selector: 'app-root',
243
- templateUrl: './app.component.html',
244
- styleUrls: ['./app.component.css'],
245
- })
246
- export class AppComponent {
247
- title = 'app';
248
- constructor(loader: SystemJsNgModuleLoader) {
249
- // Module will be split at build time and loaded when requested below
250
- loader.load('src/app/lazy/lazy.module#LazyModule')
251
- .then((factory) => { /* Use factory here */ });
252
- }
253
- }` ,
254
- } ) ;
255
- host . replaceInFile ( 'src/tsconfig.app.json' , `"module": "es2015"` , `"module": "esnext"` ) ;
256
- addLazyLoadedModulesInTsConfig ( host , lazyModuleFiles ) ;
257
- const { files } = await browserBuild ( architect , host , target , {
258
- lazyModules : [ 'src/app/lazy/lazy.module' ] ,
259
- aot : true ,
260
- } ) ;
261
-
262
- if ( ! veEnabled ) {
263
- const data = await files [ 'src-app-lazy-lazy-module.js' ] ;
264
- expect ( data ) . not . toBeUndefined ( 'Lazy module output bundle does not exist' ) ;
265
- expect ( data ) . toContain ( 'LazyModule.ɵmod' ) ;
266
- } else {
267
- expect ( files [ 'src-app-lazy-lazy-module-ngfactory.js' ] ) . not . toBeUndefined ( ) ;
268
- }
269
- } ) ;
270
194
} ) ;
0 commit comments