@@ -42,6 +42,7 @@ export interface InitialFileRecord {
4242 name ?: string ;
4343 type : 'script' | 'style' ;
4444 external ?: boolean ;
45+ serverFile : boolean ;
4546}
4647
4748export enum BuildOutputFileType {
@@ -75,7 +76,6 @@ export class BundlerContext {
7576 #esbuildResult?: BundleContextResult ;
7677 #optionsFactory: BundlerOptionsFactory < BuildOptions & { metafile : true ; write : false } > ;
7778 #shouldCacheResult: boolean ;
78-
7979 #loadCache?: MemoryLoadResultCache ;
8080 readonly watchFiles = new Set < string > ( ) ;
8181
@@ -222,7 +222,7 @@ export class BundlerContext {
222222 result = await build ( this . #esbuildOptions) ;
223223 }
224224
225- if ( this . #esbuildOptions ?. platform === 'node' ) {
225+ if ( this . #platformIsServer ) {
226226 for ( const entry of Object . values ( result . metafile . outputs ) ) {
227227 // eslint-disable-next-line @typescript-eslint/no-explicit-any
228228 ( entry as any ) [ 'ng-platform-server' ] = true ;
@@ -297,6 +297,7 @@ export class BundlerContext {
297297 name,
298298 type,
299299 entrypoint : true ,
300+ serverFile : this . #platformIsServer,
300301 } ;
301302
302303 if ( ! this . initialFilter || this . initialFilter ( record ) ) {
@@ -319,6 +320,7 @@ export class BundlerContext {
319320 type : initialImport . kind === 'import-rule' ? 'style' : 'script' ,
320321 entrypoint : false ,
321322 external : initialImport . external ,
323+ serverFile : this . #platformIsServer,
322324 } ;
323325
324326 if ( ! this . initialFilter || this . initialFilter ( record ) ) {
@@ -350,15 +352,16 @@ export class BundlerContext {
350352
351353 assert ( this . #esbuildOptions, 'esbuild options cannot be undefined.' ) ;
352354
353- const { platform, assetNames = '' } = this . #esbuildOptions;
354- const platformIsServer = platform === 'node' ;
355+ const { assetNames = '' } = this . #esbuildOptions;
355356 const mediaDirname = dirname ( assetNames ) ;
356357 const outputFiles = result . outputFiles . map ( ( file ) => {
357358 let fileType : BuildOutputFileType ;
358359 if ( dirname ( file . path ) === mediaDirname ) {
359360 fileType = BuildOutputFileType . Media ;
360361 } else {
361- fileType = platformIsServer ? BuildOutputFileType . Server : BuildOutputFileType . Browser ;
362+ fileType = this . #platformIsServer
363+ ? BuildOutputFileType . Server
364+ : BuildOutputFileType . Browser ;
362365 }
363366
364367 return convertOutputFile ( file , fileType ) ;
@@ -370,7 +373,7 @@ export class BundlerContext {
370373 outputFiles,
371374 initialFiles,
372375 externalImports : {
373- [ platformIsServer ? 'server' : 'browser' ] : externalImports ,
376+ [ this . # platformIsServer ? 'server' : 'browser' ] : externalImports ,
374377 } ,
375378 externalConfiguration : this . #esbuildOptions. external ,
376379 errors : undefined ,
@@ -392,6 +395,10 @@ export class BundlerContext {
392395 }
393396 }
394397
398+ get #platformIsServer( ) : boolean {
399+ return this . #esbuildOptions?. platform === 'node' ;
400+ }
401+
395402 /**
396403 * Invalidate a stored bundler result based on the previous watch files
397404 * and a list of changed files.
0 commit comments