From 35b33bfccb6de7da1862fc62ee8d737cbc8b3c94 Mon Sep 17 00:00:00 2001 From: Aukevanoost Date: Wed, 25 Nov 2026 08:54:04 +0100 Subject: [PATCH] fix(esbuild): set ngServerMode in exposed-module bundles (#209) @angular/core 22.2.6 reads ngServerMode unguarded during bootstrap, which throws a ReferenceError in exposed modules that bundle core, since they had neither a define nor the banner the shared bundles get (#157). --- src/tools/esbuild/angular-bundler.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tools/esbuild/angular-bundler.ts b/src/tools/esbuild/angular-bundler.ts index 33313750..55937d91 100644 --- a/src/tools/esbuild/angular-bundler.ts +++ b/src/tools/esbuild/angular-bundler.ts @@ -20,6 +20,7 @@ import { writeContextTsConfig } from './write-context-tsconfig.js'; import { createSharedMappingsPlugin } from './shared-mappings-plugin.js'; import { getScriptBuildOptions, resolveScriptSettings } from './script-options.js'; import { createSourcemapIgnorelistPlugin } from './sourcemap-ignorelist-plugin.js'; +import { NG_SERVER_MODE_BANNER } from './node-modules-bundler.js'; export async function createAngularEsbuildContext( options: NormalizedContextOptions, @@ -186,6 +187,8 @@ export async function createAngularEsbuildContext( createSourcemapIgnorelistPlugin(), ...customPlugins, ], + // Exposed modules also run during SSR, so `ngServerMode` can't be a `define` here. (#209) + banner: { js: NG_SERVER_MODE_BANNER }, define: { ...builderOptions.define, ...scriptDefine,