fix(@angular-devkit/build-angular): provide better error message when server option is required but missing

This improves the error message when the server entry-point is required but missing

Closes #27251
This commit is contained in:
Alan Agius 2024-03-11 17:34:59 +00:00 committed by Alan Agius
parent a44b6c19c4
commit 1034bb155b
2 changed files with 9 additions and 10 deletions

View File

@ -221,7 +221,7 @@ export async function normalizeOptions(
if (options.server) {
serverEntryPoint = path.join(workspaceRoot, options.server);
} else if (options.server === '') {
throw new Error('`server` option cannot be an empty string.');
throw new Error('The "server" option cannot be an empty string.');
}
let prerenderOptions;
@ -253,6 +253,12 @@ export async function normalizeOptions(
};
}
if ((appShellOptions || ssrOptions || prerenderOptions) && !serverEntryPoint) {
throw new Error(
'The "server" option is required when enabling "ssr", "prerender" or "app-shell".',
);
}
// Initial options to keep
const {
allowedCommonJsDependencies,

View File

@ -154,15 +154,8 @@ export function createServerCodeBundleOptions(
target: string[],
sourceFileCache: SourceFileCache,
): BuildOptions {
const {
jit,
serverEntryPoint,
workspaceRoot,
ssrOptions,
watch,
externalPackages,
prerenderOptions,
} = options;
const { serverEntryPoint, workspaceRoot, ssrOptions, watch, externalPackages, prerenderOptions } =
options;
assert(
serverEntryPoint,