@@ -42,6 +42,7 @@ export interface InitialFileRecord {
42
42
name ?: string ;
43
43
type : 'script' | 'style' ;
44
44
external ?: boolean ;
45
+ serverFile : boolean ;
45
46
}
46
47
47
48
export enum BuildOutputFileType {
@@ -75,7 +76,6 @@ export class BundlerContext {
75
76
#esbuildResult?: BundleContextResult ;
76
77
#optionsFactory: BundlerOptionsFactory < BuildOptions & { metafile : true ; write : false } > ;
77
78
#shouldCacheResult: boolean ;
78
-
79
79
#loadCache?: MemoryLoadResultCache ;
80
80
readonly watchFiles = new Set < string > ( ) ;
81
81
@@ -222,7 +222,7 @@ export class BundlerContext {
222
222
result = await build ( this . #esbuildOptions) ;
223
223
}
224
224
225
- if ( this . #esbuildOptions ?. platform === 'node' ) {
225
+ if ( this . #platformIsServer ) {
226
226
for ( const entry of Object . values ( result . metafile . outputs ) ) {
227
227
// eslint-disable-next-line @typescript-eslint/no-explicit-any
228
228
( entry as any ) [ 'ng-platform-server' ] = true ;
@@ -297,6 +297,7 @@ export class BundlerContext {
297
297
name,
298
298
type,
299
299
entrypoint : true ,
300
+ serverFile : this . #platformIsServer,
300
301
} ;
301
302
302
303
if ( ! this . initialFilter || this . initialFilter ( record ) ) {
@@ -319,6 +320,7 @@ export class BundlerContext {
319
320
type : initialImport . kind === 'import-rule' ? 'style' : 'script' ,
320
321
entrypoint : false ,
321
322
external : initialImport . external ,
323
+ serverFile : this . #platformIsServer,
322
324
} ;
323
325
324
326
if ( ! this . initialFilter || this . initialFilter ( record ) ) {
@@ -350,15 +352,16 @@ export class BundlerContext {
350
352
351
353
assert ( this . #esbuildOptions, 'esbuild options cannot be undefined.' ) ;
352
354
353
- const { platform, assetNames = '' } = this . #esbuildOptions;
354
- const platformIsServer = platform === 'node' ;
355
+ const { assetNames = '' } = this . #esbuildOptions;
355
356
const mediaDirname = dirname ( assetNames ) ;
356
357
const outputFiles = result . outputFiles . map ( ( file ) => {
357
358
let fileType : BuildOutputFileType ;
358
359
if ( dirname ( file . path ) === mediaDirname ) {
359
360
fileType = BuildOutputFileType . Media ;
360
361
} else {
361
- fileType = platformIsServer ? BuildOutputFileType . Server : BuildOutputFileType . Browser ;
362
+ fileType = this . #platformIsServer
363
+ ? BuildOutputFileType . Server
364
+ : BuildOutputFileType . Browser ;
362
365
}
363
366
364
367
return convertOutputFile ( file , fileType ) ;
@@ -370,7 +373,7 @@ export class BundlerContext {
370
373
outputFiles,
371
374
initialFiles,
372
375
externalImports : {
373
- [ platformIsServer ? 'server' : 'browser' ] : externalImports ,
376
+ [ this . # platformIsServer ? 'server' : 'browser' ] : externalImports ,
374
377
} ,
375
378
externalConfiguration : this . #esbuildOptions. external ,
376
379
errors : undefined ,
@@ -392,6 +395,10 @@ export class BundlerContext {
392
395
}
393
396
}
394
397
398
+ get #platformIsServer( ) : boolean {
399
+ return this . #esbuildOptions?. platform === 'node' ;
400
+ }
401
+
395
402
/**
396
403
* Invalidate a stored bundler result based on the previous watch files
397
404
* and a list of changed files.
0 commit comments