@@ -48,7 +48,7 @@ describe('Browser Builder scripts array', () => {
48
48
afterEach ( async ( ) => host . restore ( ) . toPromise ( ) ) ;
49
49
50
50
it ( 'works' , async ( ) => {
51
- const matches : { [ path : string ] : string } = {
51
+ const matches : Record < string , string > = {
52
52
'scripts.js' : 'input-script' ,
53
53
'lazy-script.js' : 'lazy-script' ,
54
54
'renamed-script.js' : 'pre-rename-script' ,
@@ -71,8 +71,41 @@ describe('Browser Builder scripts array', () => {
71
71
scripts : getScriptsOption ( ) ,
72
72
} as { } ) ;
73
73
74
- for ( const fileName of Object . keys ( matches ) ) {
75
- expect ( await files [ fileName ] ) . toMatch ( matches [ fileName ] ) ;
74
+ for ( const [ fileName , content ] of Object . entries ( matches ) ) {
75
+ expect ( await files [ fileName ] ) . toMatch ( content ) ;
76
+ }
77
+ } ) ;
78
+
79
+ it ( 'works in watch mode with differential loading' , async ( ) => {
80
+ const matches : Record < string , string > = {
81
+ 'scripts.js' : 'input-script' ,
82
+ 'lazy-script.js' : 'lazy-script' ,
83
+ 'renamed-script.js' : 'pre-rename-script' ,
84
+ 'renamed-lazy-script.js' : 'pre-rename-lazy-script' ,
85
+ 'main.js' : 'input-script' ,
86
+ 'index.html' : '<script src="runtime.js" type="module"></script>'
87
+ + '<script src="polyfills.js" type="module"></script>'
88
+ + '<script src="scripts.js" defer></script>'
89
+ + '<script src="renamed-script.js" defer></script>'
90
+ + '<script src="vendor.js" type="module"></script>'
91
+ + '<script src="main.js" type="module"></script>' ,
92
+ } ;
93
+
94
+ host . writeMultipleFiles ( scripts ) ;
95
+ host . appendToFile ( 'src/main.ts' , '\nimport \'./input-script.js\';' ) ;
96
+
97
+ // Enable differential loading
98
+ host . appendToFile ( 'browserslist' , '\nIE 10' ) ;
99
+
100
+ // Remove styles so we don't have to account for them in the index.html order check.
101
+ const { files } = await browserBuild ( architect , host , target , {
102
+ styles : [ ] ,
103
+ scripts : getScriptsOption ( ) ,
104
+ watch : true ,
105
+ } as { } ) ;
106
+
107
+ for ( const [ fileName , content ] of Object . entries ( matches ) ) {
108
+ expect ( await files [ fileName ] ) . toMatch ( content ) ;
76
109
}
77
110
} ) ;
78
111
0 commit comments