Skip to content

Commit

Permalink
fix(@angular/build): add warning when --prerendering or `--app-shel…
Browse files Browse the repository at this point in the history
…l` are no-ops

Both options are ineffective when used with `outputMode`, so a warning is now issued.
  • Loading branch information
alan-agius4 committed Oct 25, 2024
1 parent 0a1f171 commit d349ed2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
12 changes: 6 additions & 6 deletions packages/angular/build/src/builders/application/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,17 @@ export async function normalizeOptions(
options.ssr = false;
}

if (options.prerender) {
if (options.prerender !== undefined) {
context.logger.warn(
'The "prerender" option is no longer needed when "outputMode" is specified.',
'The "prerender" option is not considered when "outputMode" is specified.',
);
} else {
options.prerender = !!options.server;
}

if (options.appShell) {
options.prerender = !!options.server;

if (options.appShell !== undefined) {
context.logger.warn(
'The "appShell" option is no longer needed when "outputMode" is specified.',
'The "appShell" option is not considered when "outputMode" is specified.',
);
}
}
Expand Down
4 changes: 1 addition & 3 deletions packages/angular/build/src/builders/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@
},
"prerender": {
"description": "Prerender (SSG) pages of your application during build time.",
"default": false,
"oneOf": [
{
"type": "boolean",
Expand Down Expand Up @@ -586,8 +585,7 @@
},
"appShell": {
"type": "boolean",
"description": "Generates an application shell during build time.",
"default": false
"description": "Generates an application shell during build time."
},
"outputMode": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function* serveWithVite(
if (browserOptions.prerender || (browserOptions.outputMode && browserOptions.server)) {
// Disable prerendering if enabled and force SSR.
// This is so instead of prerendering all the routes for every change, the page is "prerendered" when it is requested.
browserOptions.prerender = false;
browserOptions.prerender = undefined;
browserOptions.ssr ||= true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ export async function extractMessages(
buildOptions.serviceWorker = false;
buildOptions.server = undefined;
buildOptions.ssr = false;
buildOptions.appShell = false;
buildOptions.prerender = false;
buildOptions.appShell = undefined;
buildOptions.prerender = undefined;
buildOptions.outputMode = undefined;

const builderResult = await first(buildApplicationInternal(buildOptions, context));

Expand Down

0 comments on commit d349ed2

Please sign in to comment.