Skip to content

Commit

Permalink
refactor(@angular/build): add globalThis['ngServerMode'] only when …
Browse files Browse the repository at this point in the history
…`externalDependencies` are present

This code is unnecessary when no external dependencies are involved.

(cherry picked from commit 43127dd)
  • Loading branch information
alan-agius4 committed Dec 10, 2024
1 parent 1047b86 commit e20e739
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ export function createServerPolyfillBundleOptions(
return;
}

const jsBanner: string[] = [`globalThis['ngServerMode'] = true;`];
const jsBanner: string[] = [];
if (polyfillBundleOptions.external?.length) {
jsBanner.push(`globalThis['ngServerMode'] = true;`);
}

if (isNodePlatform) {
// Note: Needed as esbuild does not provide require shims / proxy from ESModules.
// See: https://github.com/evanw/esbuild/issues/1921.
Expand Down Expand Up @@ -394,7 +398,11 @@ export function createSsrEntryCodeBundleOptions(
const ssrInjectManifestNamespace = 'angular:ssr-entry-inject-manifest';
const isNodePlatform = options.ssrOptions?.platform !== ExperimentalPlatform.Neutral;

const jsBanner: string[] = [`globalThis['ngServerMode'] = true;`];
const jsBanner: string[] = [];
if (options.externalDependencies?.length) {
jsBanner.push(`globalThis['ngServerMode'] = true;`);
}

if (isNodePlatform) {
// Note: Needed as esbuild does not provide require shims / proxy from ESModules.
// See: https://github.com/evanw/esbuild/issues/1921.
Expand Down

0 comments on commit e20e739

Please sign in to comment.