@@ -25,7 +25,7 @@ export type NormalizedApplicationBuildOptions = Awaited<ReturnType<typeof normal
2525/** Internal options hidden from builder schema but available when invoked programmatically. */
2626interface InternalOptions {
2727 /**
28- * Entry points to use for the compilation. Incompatible with `main `, which must not be provided. May be relative or absolute paths.
28+ * Entry points to use for the compilation. Incompatible with `browser `, which must not be provided. May be relative or absolute paths.
2929 * If given a relative path, it is resolved relative to the current workspace and will generate an output at the same relative location
3030 * in the output directory. If given an absolute path, the output will be generated in the root of the output directory with the same base
3131 * name.
@@ -42,7 +42,7 @@ interface InternalOptions {
4242 externalPackages ?: boolean ;
4343}
4444
45- /** Full set of options for `browser-esbuild ` builder. */
45+ /** Full set of options for `application ` builder. */
4646export type ApplicationBuilderInternalOptions = Omit <
4747 ApplicationBuilderOptions & InternalOptions ,
4848 'browser'
@@ -164,6 +164,13 @@ export async function normalizeOptions(
164164 } ;
165165 }
166166
167+ let serverEntryPoint : string | undefined ;
168+ if ( options . server ) {
169+ serverEntryPoint = path . join ( workspaceRoot , options . server ) ;
170+ } else if ( options . server === '' ) {
171+ throw new Error ( '`server` option cannot be an empty string.' ) ;
172+ }
173+
167174 // Initial options to keep
168175 const {
169176 allowedCommonJsDependencies,
@@ -182,7 +189,6 @@ export async function normalizeOptions(
182189 stylePreprocessorOptions,
183190 subresourceIntegrity,
184191 verbose,
185- server,
186192 watch,
187193 progress = true ,
188194 externalPackages,
@@ -210,7 +216,7 @@ export async function normalizeOptions(
210216 preserveSymlinks : preserveSymlinks ?? process . execArgv . includes ( '--preserve-symlinks' ) ,
211217 stylePreprocessorOptions,
212218 subresourceIntegrity,
213- server : ! ! server && path . join ( workspaceRoot , server ) ,
219+ serverEntryPoint ,
214220 verbose,
215221 watch,
216222 workspaceRoot,
@@ -233,39 +239,39 @@ export async function normalizeOptions(
233239}
234240
235241/**
236- * Normalize entry point options. To maintain compatibility with the legacy browser builder, we need a single `main` option which defines a
237- * single entry point. However, we also want to support multiple entry points as an internal option. The two options are mutually exclusive
238- * and if `main ` is provided it will be used as the sole entry point. If `entryPoints` are provided, they will be used as the set of entry
239- * points.
242+ * Normalize entry point options. To maintain compatibility with the legacy browser builder, we need a single `browser`
243+ * option which defines a single entry point. However, we also want to support multiple entry points as an internal option.
244+ * The two options are mutually exclusive and if `browser ` is provided it will be used as the sole entry point.
245+ * If `entryPoints` are provided, they will be used as the set of entry points.
240246 *
241247 * @param workspaceRoot Path to the root of the Angular workspace.
242- * @param main The `main ` option pointing at the application entry point. While required per the schema file, it may be omitted by
248+ * @param browser The `browser ` option pointing at the application entry point. While required per the schema file, it may be omitted by
243249 * programmatic usages of `browser-esbuild`.
244250 * @param entryPoints Set of entry points to use if provided.
245251 * @returns An object mapping entry point names to their file paths.
246252 */
247253function normalizeEntryPoints (
248254 workspaceRoot : string ,
249- main : string | undefined ,
255+ browser : string | undefined ,
250256 entryPoints : Set < string > = new Set ( ) ,
251257) : Record < string , string > {
252- if ( main === '' ) {
253- throw new Error ( '`main ` option cannot be an empty string.' ) ;
258+ if ( browser === '' ) {
259+ throw new Error ( '`browser ` option cannot be an empty string.' ) ;
254260 }
255261
256- // `main ` and `entryPoints` are mutually exclusive.
257- if ( main && entryPoints . size > 0 ) {
258- throw new Error ( 'Only one of `main ` or `entryPoints` may be provided.' ) ;
262+ // `browser ` and `entryPoints` are mutually exclusive.
263+ if ( browser && entryPoints . size > 0 ) {
264+ throw new Error ( 'Only one of `browser ` or `entryPoints` may be provided.' ) ;
259265 }
260- if ( ! main && entryPoints . size === 0 ) {
266+ if ( ! browser && entryPoints . size === 0 ) {
261267 // Schema should normally reject this case, but programmatic usages of the builder might make this mistake.
262- throw new Error ( 'Either `main ` or at least one `entryPoints` value must be provided.' ) ;
268+ throw new Error ( 'Either `browser ` or at least one `entryPoints` value must be provided.' ) ;
263269 }
264270
265- // Schema types force `main ` to always be provided, but it may be omitted when the builder is invoked programmatically.
266- if ( main ) {
267- // Use `main ` alone.
268- return { 'main' : path . join ( workspaceRoot , main ) } ;
271+ // Schema types force `browser ` to always be provided, but it may be omitted when the builder is invoked programmatically.
272+ if ( browser ) {
273+ // Use `browser ` alone.
274+ return { 'main' : path . join ( workspaceRoot , browser ) } ;
269275 } else {
270276 // Use `entryPoints` alone.
271277 const entryPointPaths : Record < string , string > = { } ;
0 commit comments