Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): provide actionable error message …
Browse files Browse the repository at this point in the history
…when server bundle is missing default export

This change improves the error message when the server bundle does not export a default export.

Closes #26922

(cherry picked from commit 1f119be)
  • Loading branch information
alan-agius4 committed Jan 23, 2024
1 parent 4e2b23f commit 45dea6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function extract(): Promise<string[]> {
const bootstrapAppFnOrModule = bootstrapAppFn || AppServerModule;
assert(
bootstrapAppFnOrModule,
`Neither an AppServerModule nor a bootstrapping function was exported from: ${serverBundlePath}.`,
`The file "${serverBundlePath}" does not have a default export for an AppServerModule or a bootstrapping function.`,
);

const routes: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import type { ApplicationRef, StaticProvider } from '@angular/core';
import assert from 'node:assert';
import { basename } from 'node:path';
import { loadEsmModule } from '../load-esm';
import { MainServerBundleExports, RenderUtilsServerBundleExports } from './main-bundle-exports';
Expand Down Expand Up @@ -73,6 +74,10 @@ export async function renderPage({
];

let html: string | undefined;
assert(
bootstrapAppFnOrModule,
'The file "./main.server.mjs" does not have a default export for an AppServerModule or a bootstrapping function.',
);

if (isBootstrapFn(bootstrapAppFnOrModule)) {
html = await renderApplication(bootstrapAppFnOrModule, {
Expand Down

0 comments on commit 45dea6f

Please sign in to comment.