Repository navigation
fix(esbuild): set ngServerMode in exposed-module bundles - #211
Merged
Merged
Conversation
@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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #209
@angular/core22.2.6 readsngServerModewithout atypeofguard during bootstrap, added by angular/angular@c33b0e3 ("validate the APP_ID value on the server", not listed in the release notes) (bootstrapModuleFactoryand thebootstrapApplication/createApplicationpath):In production builds
ngDevModeisfalse, so the read always runs. Angular's own browser build definesngServerMode, and our shared bundles getNG_SERVER_MODE_BANNER(#157), but exposed-module bundles had neither. An exposed module that bundles@angular/coreand bootstraps itself therefore throwsReferenceError: ngServerMode is not defined.This adds the same banner to the exposed-module build. A
definewould be wrong because exposed modules also run during SSR; the banner only fills in the value when it is undefined, so the server'strueis kept.Not yet verified end-to-end against a remote on 22.2.6; typecheck, lint and existing tests pass.