@@ -58,7 +58,7 @@ describe('ng program', () => {
58
58
59
59
function compile (
60
60
oldProgram ?: ng . Program , overrideOptions ?: ng . CompilerOptions , rootNames ?: string [ ] ,
61
- host ?: CompilerHost ) : ng . Program {
61
+ host ?: CompilerHost ) : { program : ng . Program , emitResult : ts . EmitResult } {
62
62
const options = testSupport . createCompilerOptions ( overrideOptions ) ;
63
63
if ( ! rootNames ) {
64
64
rootNames = [ path . resolve ( testSupport . basePath , 'src/index.ts' ) ] ;
@@ -73,8 +73,8 @@ describe('ng program', () => {
73
73
oldProgram,
74
74
} ) ;
75
75
expectNoDiagnosticsInProgram ( options , program ) ;
76
- program . emit ( ) ;
77
- return program ;
76
+ const emitResult = program . emit ( ) ;
77
+ return { emitResult , program} ;
78
78
}
79
79
80
80
describe ( 'reuse of old program' , ( ) => {
@@ -87,14 +87,14 @@ describe('ng program', () => {
87
87
export * from 'lib/index';
88
88
`
89
89
} ) ;
90
- const p1 = compile ( ) ;
90
+ const p1 = compile ( ) . program ;
91
91
expect ( p1 . getTsProgram ( ) . getSourceFiles ( ) . some (
92
92
sf => / n o d e _ m o d u l e s \/ l i b \/ .* \. n g f a c t o r y \. t s $ / . test ( sf . fileName ) ) )
93
93
. toBe ( true ) ;
94
94
expect ( p1 . getTsProgram ( ) . getSourceFiles ( ) . some (
95
95
sf => / n o d e _ m o d u l e s \/ l i b 2 \/ .* \. n g f a c t o r y .* $ / . test ( sf . fileName ) ) )
96
96
. toBe ( false ) ;
97
- const p2 = compile ( p1 ) ;
97
+ const p2 = compile ( p1 ) . program ;
98
98
expect ( p2 . getTsProgram ( ) . getSourceFiles ( ) . some (
99
99
sf => / n o d e _ m o d u l e s \/ l i b \/ .* \. n g f a c t o r y .* $ / . test ( sf . fileName ) ) )
100
100
. toBe ( false ) ;
@@ -111,15 +111,15 @@ describe('ng program', () => {
111
111
export * from 'lib2/index';
112
112
` ,
113
113
} ) ;
114
- const p3 = compile ( p2 ) ;
114
+ const p3 = compile ( p2 ) . program ;
115
115
expect ( p3 . getTsProgram ( ) . getSourceFiles ( ) . some (
116
116
sf => / n o d e _ m o d u l e s \/ l i b \/ .* \. n g f a c t o r y .* $ / . test ( sf . fileName ) ) )
117
117
. toBe ( false ) ;
118
118
expect ( p3 . getTsProgram ( ) . getSourceFiles ( ) . some (
119
119
sf => / n o d e _ m o d u l e s \/ l i b 2 \/ .* \. n g f a c t o r y \. t s $ / . test ( sf . fileName ) ) )
120
120
. toBe ( true ) ;
121
121
122
- const p4 = compile ( p3 ) ;
122
+ const p4 = compile ( p3 ) . program ;
123
123
expect ( p4 . getTsProgram ( ) . getSourceFiles ( ) . some (
124
124
sf => / n o d e _ m o d u l e s \/ l i b \/ .* \. n g f a c t o r y .* $ / . test ( sf . fileName ) ) )
125
125
. toBe ( false ) ;
@@ -140,14 +140,14 @@ describe('ng program', () => {
140
140
export * from 'lib/index';
141
141
`
142
142
} ) ;
143
- const p1 = compile ( undefined , { declaration : false } ) ;
143
+ const p1 = compile ( undefined , { declaration : false } ) . program ;
144
144
expect ( p1 . getTsProgram ( ) . getSourceFiles ( ) . some (
145
145
sf => / n o d e _ m o d u l e s \/ l i b \/ .* \. n g f a c t o r y \. t s $ / . test ( sf . fileName ) ) )
146
146
. toBe ( true ) ;
147
147
expect ( p1 . getTsProgram ( ) . getSourceFiles ( ) . some (
148
148
sf => / n o d e _ m o d u l e s \/ l i b 2 \/ .* \. n g f a c t o r y .* $ / . test ( sf . fileName ) ) )
149
149
. toBe ( false ) ;
150
- const p2 = compile ( p1 , { declaration : false } ) ;
150
+ const p2 = compile ( p1 , { declaration : false } ) . program ;
151
151
expect ( p2 . getTsProgram ( ) . getSourceFiles ( ) . some (
152
152
sf => / n o d e _ m o d u l e s \/ l i b \/ .* \. n g f a c t o r y .* $ / . test ( sf . fileName ) ) )
153
153
. toBe ( false ) ;
@@ -178,37 +178,49 @@ describe('ng program', () => {
178
178
host . writeFile = ( fileName : string , data : string ) => written . set ( fileName , data ) ;
179
179
180
180
// compile libraries
181
- const p1 = compile ( undefined , options , undefined , host ) ;
181
+ const p1 = compile ( undefined , options , undefined , host ) . program ;
182
182
183
183
// first compile without libraries
184
- const p2 = compile ( p1 , options , undefined , host ) ;
184
+ const p2 = compile ( p1 , options , undefined , host ) . program ;
185
185
expect ( written . has ( path . resolve ( testSupport . basePath , 'built/src/index.js' ) ) ) . toBe ( true ) ;
186
186
let ngFactoryContent =
187
187
written . get ( path . resolve ( testSupport . basePath , 'built/src/index.ngfactory.js' ) ) ;
188
188
expect ( ngFactoryContent ) . toMatch ( / S t a r t / ) ;
189
189
190
190
// no change -> no emit
191
191
written . clear ( ) ;
192
- const p3 = compile ( p2 , options , undefined , host ) ;
192
+ const p3 = compile ( p2 , options , undefined , host ) . program ;
193
193
expect ( written . size ) . toBe ( 0 ) ;
194
194
195
195
// change a user file
196
196
written . clear ( ) ;
197
197
fileCache . delete ( path . resolve ( testSupport . basePath , 'src/index.ts' ) ) ;
198
- const p4 = compile ( p3 , options , undefined , host ) ;
198
+ const p4 = compile ( p3 , options , undefined , host ) . program ;
199
199
expect ( written . size ) . toBe ( 1 ) ;
200
200
expect ( written . has ( path . resolve ( testSupport . basePath , 'built/src/index.js' ) ) ) . toBe ( true ) ;
201
201
202
202
// change a file that is input to generated files
203
203
written . clear ( ) ;
204
204
testSupport . writeFiles ( { 'src/index.html' : 'Hello' } ) ;
205
- const p5 = compile ( p4 , options , undefined , host ) ;
205
+ compile ( p4 , options , undefined , host ) ;
206
206
expect ( written . size ) . toBe ( 1 ) ;
207
207
ngFactoryContent =
208
208
written . get ( path . resolve ( testSupport . basePath , 'built/src/index.ngfactory.js' ) ) ;
209
209
expect ( ngFactoryContent ) . toMatch ( / H e l l o / ) ;
210
210
} ) ;
211
211
212
+ it ( 'should set emitSkipped to false for full and incremental emit' , ( ) => {
213
+ testSupport . writeFiles ( {
214
+ 'src/index.ts' : createModuleAndCompSource ( 'main' ) ,
215
+ } ) ;
216
+ const { emitResult : emitResult1 , program : p1 } = compile ( ) ;
217
+ expect ( emitResult1 . emitSkipped ) . toBe ( false ) ;
218
+ const { emitResult : emitResult2 , program : p2 } = compile ( p1 ) ;
219
+ expect ( emitResult2 . emitSkipped ) . toBe ( false ) ;
220
+ const { emitResult : emitResult3 , program : p3 } = compile ( p2 ) ;
221
+ expect ( emitResult3 . emitSkipped ) . toBe ( false ) ;
222
+ } ) ;
223
+
212
224
it ( 'should store library summaries on emit' , ( ) => {
213
225
compileLib ( 'lib' ) ;
214
226
testSupport . writeFiles ( {
@@ -218,7 +230,7 @@ describe('ng program', () => {
218
230
export * from 'lib/index';
219
231
`
220
232
} ) ;
221
- const p1 = compile ( ) ;
233
+ const p1 = compile ( ) . program ;
222
234
expect ( Array . from ( p1 . getLibrarySummaries ( ) . values ( ) )
223
235
. some ( sf => / n o d e _ m o d u l e s \/ l i b \/ i n d e x \. n g f a c t o r y \. d \. t s $ / . test ( sf . fileName ) ) )
224
236
. toBe ( true ) ;
@@ -238,9 +250,9 @@ describe('ng program', () => {
238
250
testSupport . writeFiles ( { 'src/index.ts' : createModuleAndCompSource ( 'main' ) } ) ;
239
251
// Note: the second compile drops factories for library files,
240
252
// and therefore changes the structure again
241
- const p1 = compile ( ) ;
242
- const p2 = compile ( p1 ) ;
243
- const p3 = compile ( p2 ) ;
253
+ const p1 = compile ( ) . program ;
254
+ const p2 = compile ( p1 ) . program ;
255
+ compile ( p2 ) ;
244
256
expect ( tsStructureIsReused ( p2 . getTsProgram ( ) ) ) . toBe ( StructureIsReused . Completely ) ;
245
257
} ) ;
246
258
@@ -256,13 +268,13 @@ describe('ng program', () => {
256
268
} ) ;
257
269
// Note: the second compile drops factories for library files,
258
270
// and therefore changes the structure again
259
- const p1 = compile ( ) ;
260
- const p2 = compile ( p1 ) ;
271
+ const p1 = compile ( ) . program ;
272
+ const p2 = compile ( p1 ) . program ;
261
273
testSupport . writeFiles ( {
262
274
'src/main.html' : `Another template` ,
263
275
'src/util.ts' : `export const x = 2` ,
264
276
} ) ;
265
- const p3 = compile ( p2 ) ;
277
+ compile ( p2 ) ;
266
278
expect ( tsStructureIsReused ( p2 . getTsProgram ( ) ) ) . toBe ( StructureIsReused . Completely ) ;
267
279
} ) ;
268
280
@@ -277,11 +289,11 @@ describe('ng program', () => {
277
289
} ) ;
278
290
// Note: the second compile drops factories for library files,
279
291
// and therefore changes the structure again
280
- const p1 = compile ( ) ;
281
- const p2 = compile ( p1 ) ;
292
+ const p1 = compile ( ) . program ;
293
+ const p2 = compile ( p1 ) . program ;
282
294
testSupport . writeFiles (
283
295
{ 'src/util.ts' : `import {Injectable} from '@angular/core'; export const x = 1;` } ) ;
284
- const p3 = compile ( p2 ) ;
296
+ compile ( p2 ) ;
285
297
expect ( tsStructureIsReused ( p2 . getTsProgram ( ) ) ) . toBe ( StructureIsReused . SafeModules ) ;
286
298
} ) ;
287
299
} ) ;
0 commit comments