@@ -172,106 +172,18 @@ describe('BuilderState', () => {
172172 ) . toBeFalse ( ) ;
173173 } ) ;
174174
175- it ( 'should invalidate hasEmittedManifests and compiled bundle state when compilationMode changes' , ( ) => {
175+ it ( 'should invalidate hasEmittedManifests when compilationMode changes' , ( ) => {
176176 const state = new BuilderState ( ) ;
177177 state . hasEmittedManifests = true ;
178- const firstCache = createMockCache ( ) ;
179- firstCache . esmFiles . set ( '/src/index.js' , 'export const a = 1;' ) ;
180- firstCache . dtsFiles . set ( '/src/index.d.ts' , 'export declare const a: number;' ) ;
181-
182- state . recordCompilationOutput (
183- createMockCompilationOutput ( {
184- compilationMode : 'partial' ,
185- cache : firstCache ,
186- esmFiles : firstCache . esmFiles ,
187- dtsFiles : firstCache . dtsFiles ,
188- } ) ,
189- ) ;
178+ state . recordCompilationOutput ( createMockCompilationOutput ( { compilationMode : 'partial' } ) ) ;
190179 expect ( state . hasEmittedManifests ) . toBeFalse ( ) ;
191180
192- state . recordBundleOutput (
193- new Map ( [
194- [
195- '.' ,
196- {
197- esmModuleIds : new Set ( [ '/src/index.js' ] ) ,
198- dtsModuleIds : new Set ( [ '/src/index.d.ts' ] ) ,
199- esmOutputFiles : new Set ( [ 'fesm2022/my-lib.mjs' ] ) ,
200- dtsOutputFiles : new Set ( [ 'types/my-lib.d.ts' ] ) ,
201- hasTslibImport : false ,
202- } ,
203- ] ,
204- ] ) ,
205- ) ;
206181 state . hasEmittedManifests = true ;
207-
208- state . recordCompilationOutput (
209- createMockCompilationOutput ( {
210- compilationMode : 'partial' ,
211- cache : firstCache ,
212- esmFiles : firstCache . esmFiles ,
213- dtsFiles : firstCache . dtsFiles ,
214- } ) ,
215- ) ;
182+ state . recordCompilationOutput ( createMockCompilationOutput ( { compilationMode : 'partial' } ) ) ;
216183 expect ( state . hasEmittedManifests ) . toBeTrue ( ) ;
217- expect ( state . previousBundleResults . size ) . toBe ( 1 ) ;
218-
219- const secondCache = createMockCache ( ) ;
220- secondCache . esmFiles . set ( '/src/index.js' , 'export const a = 2;' ) ;
221- secondCache . dtsFiles . set ( '/src/index.d.ts' , 'export declare const a: number;' ) ;
222184
223- state . recordCompilationOutput (
224- createMockCompilationOutput ( {
225- compilationMode : 'full' ,
226- cache : secondCache ,
227- esmFiles : secondCache . esmFiles ,
228- dtsFiles : secondCache . dtsFiles ,
229- } ) ,
230- ) ;
185+ state . recordCompilationOutput ( createMockCompilationOutput ( { compilationMode : 'full' } ) ) ;
231186 expect ( state . hasEmittedManifests ) . toBeFalse ( ) ;
232- expect ( state . previousBundleResults . size ) . toBe ( 0 ) ;
233- expect ( firstCache . esmFiles . size ) . toBe ( 0 ) ;
234- expect ( firstCache . dtsFiles . size ) . toBe ( 0 ) ;
235- expect ( state . pendingChangedEsmFiles ) . toEqual ( new Set ( [ '/src/index.js' ] ) ) ;
236- expect ( state . pendingChangedDtsFiles ) . toEqual ( new Set ( [ '/src/index.d.ts' ] ) ) ;
237- } ) ;
238-
239- it ( 'should mark entry point DTS files dirty when declarationMap changes' , ( ) => {
240- const state = new BuilderState ( ) ;
241- state . recordCompilationOutput (
242- createMockCompilationOutput ( {
243- declarationMap : false ,
244- dtsFiles : new Map ( [ [ '/src/index.d.ts' , 'export declare const a: number;' ] ] ) ,
245- } ) ,
246- ) ;
247- state . recordBundleOutput (
248- new Map ( [
249- [
250- '.' ,
251- {
252- esmModuleIds : new Set ( [ '/src/index.js' ] ) ,
253- dtsModuleIds : new Set ( [ '/src/index.d.ts' ] ) ,
254- esmOutputFiles : new Set ( [ 'fesm2022/my-lib.mjs' ] ) ,
255- dtsOutputFiles : new Set ( [ 'types/my-lib.d.ts' ] ) ,
256- hasTslibImport : false ,
257- } ,
258- ] ,
259- ] ) ,
260- ) ;
261- expect ( state . pendingChangedDtsFiles . size ) . toBe ( 0 ) ;
262-
263- state . recordCompilationOutput (
264- createMockCompilationOutput ( {
265- declarationMap : true ,
266- dtsFiles : new Map ( [
267- [ '/src/index.d.ts' , 'export declare const a: number;' ] ,
268- [ '/src/index.d.ts.map' , '{}' ] ,
269- ] ) ,
270- } ) ,
271- ) ;
272- expect ( state . declarationMap ) . toBeTrue ( ) ;
273- expect ( state . pendingChangedDtsFiles ) . toEqual ( new Set ( [ '/src/index.d.ts' ] ) ) ;
274- expect ( state . pendingChangedEsmFiles . size ) . toBe ( 0 ) ;
275187 } ) ;
276188 } ) ;
277189
@@ -393,7 +305,7 @@ describe('BuilderState', () => {
393305 workspaceRoot : tempRoot ,
394306 assets : [ { glob : 'README.md' , input : tempRoot , output : '.' } ] ,
395307 } ;
396- const state = new BuilderState ( options ) ;
308+ const state = new BuilderState ( ) ;
397309
398310 // Initial build emits README.md
399311 const initialAssets = await state . collectAssets ( options ) ;
@@ -445,7 +357,7 @@ describe('BuilderState', () => {
445357 } ;
446358
447359 // Constructing BuilderState should not compile asset matchers
448- const state = new BuilderState ( options ) ;
360+ const state = new BuilderState ( ) ;
449361 expect ( globAccessCount ) . toBe ( 0 ) ;
450362
451363 state . recordEmittedOutputs ( { filesToEmit : [ ] , filesToDelete : [ ] } ) ;
@@ -465,35 +377,6 @@ describe('BuilderState', () => {
465377 }
466378 } ) ;
467379
468- it ( 'should prune non-asset paths from pendingAssetFiles after collectAssets' , async ( ) => {
469- const baseTmpDir = process . env [ 'TEST_TMPDIR' ] ;
470- assert ( baseTmpDir , 'TEST_TMPDIR is not set' ) ;
471- const tempRoot = await mkdtemp ( join ( baseTmpDir , 'angular-cli-builder-state-prune-' ) ) ;
472-
473- try {
474- const options = {
475- workspaceRoot : tempRoot ,
476- assets : [ { glob : '**/*.txt' , input : tempRoot , output : '.' } ] ,
477- } ;
478- const state = new BuilderState ( options ) ;
479- state . recordEmittedOutputs ( { filesToEmit : [ ] , filesToDelete : [ ] } ) ;
480-
481- // Pass a path that does not exist on disk yet, so it produces no asset output on iteration 1
482- const transientPath = join ( tempRoot , 'transient.txt' ) ;
483- const firstCollect = await state . collectAssets ( options , new Set ( [ transientPath ] ) ) ;
484- expect ( firstCollect . filesToEmit ) . toHaveSize ( 0 ) ;
485-
486- // Now create transientPath on disk, but trigger collectAssets with only a non-asset .ts file.
487- // Because transientPath was pruned after the first collectAssets call, it should not be emitted.
488- await writeFile ( transientPath , 'created later' ) ;
489- const nonAssetFile = join ( tempRoot , 'src/index.ts' ) ;
490- const secondCollect = await state . collectAssets ( options , new Set ( [ nonAssetFile ] ) ) ;
491- expect ( secondCollect . filesToEmit ) . toHaveSize ( 0 ) ;
492- } finally {
493- await rm ( tempRoot , { recursive : true , force : true } ) ;
494- }
495- } ) ;
496-
497380 it ( 'should close compilationInstance and clear cached state on dispose' , async ( ) => {
498381 const closeSpy = jasmine . createSpy ( 'close' ) . and . resolveTo ( ) ;
499382 const state = new BuilderState ( { packageJsonPath } ) ;
0 commit comments