Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): provide better error message when…
Browse files Browse the repository at this point in the history
… server option is required but missing

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

Closes #27251

(cherry picked from commit 1034bb1)
  • Loading branch information
alan-agius4 committed Mar 12, 2024
1 parent 9999fdd commit de2d050
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit de2d050

Please sign in to comment.