@@ -25,7 +25,7 @@ export type NormalizedApplicationBuildOptions = Awaited<ReturnType<typeof normal
25
25
/** Internal options hidden from builder schema but available when invoked programmatically. */
26
26
interface InternalOptions {
27
27
/**
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.
29
29
* If given a relative path, it is resolved relative to the current workspace and will generate an output at the same relative location
30
30
* 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
31
31
* name.
@@ -42,7 +42,7 @@ interface InternalOptions {
42
42
externalPackages ?: boolean ;
43
43
}
44
44
45
- /** Full set of options for `browser-esbuild ` builder. */
45
+ /** Full set of options for `application ` builder. */
46
46
export type ApplicationBuilderInternalOptions = Omit <
47
47
ApplicationBuilderOptions & InternalOptions ,
48
48
'browser'
@@ -164,6 +164,13 @@ export async function normalizeOptions(
164
164
} ;
165
165
}
166
166
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
+
167
174
// Initial options to keep
168
175
const {
169
176
allowedCommonJsDependencies,
@@ -182,7 +189,6 @@ export async function normalizeOptions(
182
189
stylePreprocessorOptions,
183
190
subresourceIntegrity,
184
191
verbose,
185
- server,
186
192
watch,
187
193
progress = true ,
188
194
externalPackages,
@@ -210,7 +216,7 @@ export async function normalizeOptions(
210
216
preserveSymlinks : preserveSymlinks ?? process . execArgv . includes ( '--preserve-symlinks' ) ,
211
217
stylePreprocessorOptions,
212
218
subresourceIntegrity,
213
- server : ! ! server && path . join ( workspaceRoot , server ) ,
219
+ serverEntryPoint ,
214
220
verbose,
215
221
watch,
216
222
workspaceRoot,
@@ -233,39 +239,39 @@ export async function normalizeOptions(
233
239
}
234
240
235
241
/**
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.
240
246
*
241
247
* @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
243
249
* programmatic usages of `browser-esbuild`.
244
250
* @param entryPoints Set of entry points to use if provided.
245
251
* @returns An object mapping entry point names to their file paths.
246
252
*/
247
253
function normalizeEntryPoints (
248
254
workspaceRoot : string ,
249
- main : string | undefined ,
255
+ browser : string | undefined ,
250
256
entryPoints : Set < string > = new Set ( ) ,
251
257
) : 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.' ) ;
254
260
}
255
261
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.' ) ;
259
265
}
260
- if ( ! main && entryPoints . size === 0 ) {
266
+ if ( ! browser && entryPoints . size === 0 ) {
261
267
// 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.' ) ;
263
269
}
264
270
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 ) } ;
269
275
} else {
270
276
// Use `entryPoints` alone.
271
277
const entryPointPaths : Record < string , string > = { } ;
0 commit comments