@@ -34,17 +34,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
34
34
} ;
35
35
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
36
36
exports . setupServer = exports . serveWithVite = void 0 ;
37
- const build_1 = require ( "@angular/build" ) ;
38
- const private_1 = require ( "@angular/build/private" ) ;
39
37
const node_assert_1 = __importDefault ( require ( "node:assert" ) ) ;
40
38
const promises_1 = require ( "node:fs/promises" ) ;
41
39
const node_path_1 = require ( "node:path" ) ;
42
40
const angular_memory_plugin_1 = require ( "../../tools/vite/angular-memory-plugin" ) ;
43
41
const i18n_locale_plugin_1 = require ( "../../tools/vite/i18n-locale-plugin" ) ;
44
42
const utils_1 = require ( "../../utils" ) ;
45
43
const load_esm_1 = require ( "../../utils/load-esm" ) ;
46
- const webpack_browser_config_1 = require ( "../../utils/webpack-browser-config" ) ;
47
44
const browser_esbuild_1 = require ( "../browser-esbuild" ) ;
45
+ const internal_1 = require ( "./internal" ) ;
48
46
/**
49
47
* Build options that are also present on the dev server but are only passed
50
48
* to the build.
@@ -94,15 +92,20 @@ async function* serveWithVite(serverOptions, builderName, context, transformers,
94
92
}
95
93
const { vendor : thirdPartySourcemaps } = ( 0 , utils_1 . normalizeSourceMaps ) ( browserOptions . sourceMap ?? false ) ;
96
94
// Setup the prebundling transformer that will be shared across Vite prebundling requests
97
- const prebundleTransformer = new private_1 . JavaScriptTransformer (
95
+ const prebundleTransformer = new internal_1 . JavaScriptTransformer (
98
96
// Always enable JIT linking to support applications built with and without AOT.
99
97
// In a development environment the additional scope information does not
100
98
// have a negative effect unlike production where final output size is relevant.
101
99
{ sourcemap : true , jit : true , thirdPartySourcemaps } , 1 ) ;
102
100
// Extract output index from options
103
101
// TODO: Provide this info from the build results
104
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
- const htmlIndexPath = ( 0 , webpack_browser_config_1 . getIndexOutputFile ) ( browserOptions . index ) ;
102
+ let htmlIndexPath = 'index.html' ;
103
+ if ( browserOptions . index && typeof browserOptions . index !== 'boolean' ) {
104
+ htmlIndexPath =
105
+ typeof browserOptions . index === 'string'
106
+ ? ( 0 , node_path_1 . basename ) ( browserOptions . index )
107
+ : browserOptions . index . output || 'index.html' ;
108
+ }
106
109
// dynamically import Vite for ESM compatibility
107
110
const { createServer, normalizePath } = await ( 0 , load_esm_1 . loadEsmModule ) ( 'vite' ) ;
108
111
let server ;
@@ -124,7 +127,7 @@ async function* serveWithVite(serverOptions, builderName, context, transformers,
124
127
} ) ;
125
128
const build = builderName === '@angular-devkit/build-angular:browser-esbuild'
126
129
? browser_esbuild_1 . buildEsbuildBrowser . bind ( undefined , browserOptions , context , { write : false } , extensions ?. buildPlugins )
127
- : private_1 . buildApplicationInternal . bind ( undefined , browserOptions , context , { write : false } , { codePlugins : extensions ?. buildPlugins } ) ;
130
+ : internal_1 . buildApplicationInternal . bind ( undefined , browserOptions , context , { write : false } , { codePlugins : extensions ?. buildPlugins } ) ;
128
131
// TODO: Switch this to an architect schedule call when infrastructure settings are supported
129
132
for await ( const result of build ( ) ) {
130
133
( 0 , node_assert_1 . default ) ( result . outputFiles , 'Builder did not provide result files.' ) ;
@@ -191,13 +194,13 @@ async function* serveWithVite(serverOptions, builderName, context, transformers,
191
194
}
192
195
const { root = '' } = await context . getProjectMetadata ( projectName ) ;
193
196
const projectRoot = ( 0 , node_path_1 . join ) ( context . workspaceRoot , root ) ;
194
- const browsers = ( 0 , private_1 . getSupportedBrowsers ) ( projectRoot , context . logger ) ;
195
- const target = ( 0 , private_1 . transformSupportedBrowsersToTargets ) ( browsers ) ;
197
+ const browsers = ( 0 , internal_1 . getSupportedBrowsers ) ( projectRoot , context . logger ) ;
198
+ const target = ( 0 , internal_1 . transformSupportedBrowsersToTargets ) ( browsers ) ;
196
199
const polyfills = Array . isArray ( ( browserOptions . polyfills ??= [ ] ) )
197
200
? browserOptions . polyfills
198
201
: [ browserOptions . polyfills ] ;
199
202
// Setup server and start listening
200
- const serverConfiguration = await setupServer ( serverOptions , generatedFiles , assetFiles , browserOptions . preserveSymlinks , externalMetadata , ! ! browserOptions . ssr , prebundleTransformer , target , ( 0 , private_1 . isZonelessApp ) ( polyfills ) , browserOptions . loader , extensions ?. middleware , transformers ?. indexHtml , thirdPartySourcemaps ) ;
203
+ const serverConfiguration = await setupServer ( serverOptions , generatedFiles , assetFiles , browserOptions . preserveSymlinks , externalMetadata , ! ! browserOptions . ssr , prebundleTransformer , target , ( 0 , internal_1 . isZonelessApp ) ( polyfills ) , browserOptions . loader , extensions ?. middleware , transformers ?. indexHtml , thirdPartySourcemaps ) ;
201
204
server = await createServer ( serverConfiguration ) ;
202
205
await server . listen ( ) ;
203
206
if ( serverConfiguration . ssr ?. optimizeDeps ?. disabled === false ) {
@@ -300,7 +303,7 @@ function analyzeResultFiles(normalizePath, htmlIndexPath, resultFiles, generated
300
303
if ( filePath . endsWith ( '.map' ) ) {
301
304
generatedFiles . set ( filePath , {
302
305
contents : file . contents ,
303
- servable : file . type === build_1 . BuildOutputFileType . Browser || file . type === build_1 . BuildOutputFileType . Media ,
306
+ servable : file . type === internal_1 . BuildOutputFileType . Browser || file . type === internal_1 . BuildOutputFileType . Media ,
304
307
size : file . contents . byteLength ,
305
308
updated : false ,
306
309
} ) ;
@@ -320,7 +323,7 @@ function analyzeResultFiles(normalizePath, htmlIndexPath, resultFiles, generated
320
323
size : file . contents . byteLength ,
321
324
hash : file . hash ,
322
325
updated : true ,
323
- servable : file . type === build_1 . BuildOutputFileType . Browser || file . type === build_1 . BuildOutputFileType . Media ,
326
+ servable : file . type === internal_1 . BuildOutputFileType . Browser || file . type === internal_1 . BuildOutputFileType . Media ,
324
327
} ) ;
325
328
}
326
329
// Clear stale output files
@@ -482,7 +485,7 @@ function getDepOptimizationConfig({ disabled, exclude, include, target, zoneless
482
485
} ,
483
486
] ;
484
487
if ( ssr ) {
485
- plugins . unshift ( ( 0 , private_1 . createRxjsEsmResolutionPlugin ) ( ) ) ;
488
+ plugins . unshift ( ( 0 , internal_1 . createRxjsEsmResolutionPlugin ) ( ) ) ;
486
489
}
487
490
return {
488
491
// Exclude any explicitly defined dependencies (currently build defined externals)
@@ -495,7 +498,7 @@ function getDepOptimizationConfig({ disabled, exclude, include, target, zoneless
495
498
esbuildOptions : {
496
499
// Set esbuild supported targets.
497
500
target,
498
- supported : ( 0 , private_1 . getFeatureSupport ) ( target , zoneless ) ,
501
+ supported : ( 0 , internal_1 . getFeatureSupport ) ( target , zoneless ) ,
499
502
plugins,
500
503
loader,
501
504
} ,
0 commit comments