@@ -70,10 +70,11 @@ export class ComponentCompiler {
7070 async compile ( noThrow = true , options : CompileOptions ) : Promise < BuildResult > {
7171 let dataToPersist ;
7272 const deleteDistDir = options . deleteDistDir ?? this . compilerInstance . deleteDistDir ;
73+ const distDirs = await this . distDirs ( ) ;
7374 // delete dist folder before transpilation (because some compilers (like ngPackagr) can generate files there during the compilation process)
7475 if ( deleteDistDir ) {
7576 dataToPersist = new DataToPersist ( ) ;
76- for ( const distDir of await this . distDirs ( ) ) {
77+ for ( const distDir of distDirs ) {
7778 dataToPersist . removePath ( new RemovePath ( distDir ) ) ;
7879 }
7980 dataToPersist . addBasePath ( this . workspace . path ) ;
@@ -88,12 +89,14 @@ export class ComponentCompiler {
8889
8990 if ( canTranspileFile ) {
9091 await Promise . all (
91- this . component . filesystem . files . map ( ( file : AbstractVinyl ) => this . compileOneFile ( file , options . initiator ) )
92+ this . component . filesystem . files . map ( ( file : AbstractVinyl ) =>
93+ this . compileOneFile ( file , options . initiator , distDirs )
94+ )
9295 ) ;
9396 }
9497
9598 if ( canTranspileComponent ) {
96- await this . compileAllFiles ( this . component , options . initiator ) ;
99+ await this . compileAllFiles ( this . component , options . initiator , distDirs ) ;
97100 }
98101
99102 if ( ! canTranspileFile && ! canTranspileComponent ) {
@@ -158,7 +161,11 @@ ${this.compileErrors.map(formatError).join('\n')}`);
158161 return this . workspace . componentDir ( this . component . id ) ;
159162 }
160163
161- private async compileOneFile ( file : AbstractVinyl , initiator : CompilationInitiator ) : Promise < void > {
164+ private async compileOneFile (
165+ file : AbstractVinyl ,
166+ initiator : CompilationInitiator ,
167+ distDirs : PathOsBasedRelative [ ]
168+ ) : Promise < void > {
162169 const options = { componentDir : this . componentDir , filePath : file . relative , initiator } ;
163170 const isFileSupported = this . compilerInstance . isFileSupported ( file . path ) ;
164171 let compileResults ;
@@ -170,7 +177,7 @@ ${this.compileErrors.map(formatError).join('\n')}`);
170177 return ;
171178 }
172179 }
173- for ( const base of await this . distDirs ( ) ) {
180+ for ( const base of distDirs ) {
174181 if ( isFileSupported && compileResults ) {
175182 this . dists . push (
176183 ...compileResults . map (
@@ -189,9 +196,13 @@ ${this.compileErrors.map(formatError).join('\n')}`);
189196 }
190197 }
191198
192- private async compileAllFiles ( component : Component , initiator : CompilationInitiator ) : Promise < void > {
199+ private async compileAllFiles (
200+ component : Component ,
201+ initiator : CompilationInitiator ,
202+ distDirs : PathOsBasedRelative [ ]
203+ ) : Promise < void > {
193204 const filesToCompile : AbstractVinyl [ ] = [ ] ;
194- for ( const base of await this . distDirs ( ) ) {
205+ for ( const base of distDirs ) {
195206 component . filesystem . files . forEach ( ( file : AbstractVinyl ) => {
196207 const isFileSupported = this . compilerInstance . isFileSupported ( file . path ) ;
197208 if ( isFileSupported ) {
@@ -324,7 +335,6 @@ export class WorkspaceCompiler {
324335 const getManyOpts =
325336 options . initiator === CompilationInitiator . AspectLoadFail ? { loadSeedersAsAspects : false } : undefined ;
326337 const components = await this . workspace . getMany ( componentIds , getManyOpts ) ;
327-
328338 const grouped = this . groupByIsEnv ( components ) ;
329339 const envsResults = grouped . envs ? await this . runCompileComponents ( grouped . envs , options , noThrow ) : [ ] ;
330340 const otherResults = grouped . other ? await this . runCompileComponents ( grouped . other , options , noThrow ) : [ ] ;
0 commit comments