Repository navigation
perf(@angular/build): avoid duplicate Domino bundling in server bundles - #34527
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces two new esbuild plugins to ensure Domino is bundled only once for the server. The first plugin exposes the Domino instance on globalThis within the server polyfills bundle, and the second redirects Domino imports in the main server bundle to consume this global instance. Behavior tests have also been added to verify this sharing. The review feedback highlights a potential runtime issue where exporting Domino as a default export in the consumer plugin could break namespace imports, and suggests using CommonJS module.exports to ensure compatibility.
Avoid bundling duplicate copies of Domino in both the server polyfills bundle and the main server bundle. The server polyfills bundle exposes the Domino instance attached to globalThis['ɵdomino'] when @angular/platform-server/init is bundled, and the main server bundle redirects Domino imports to this shared instance.
7814f94 to
58f0583
Compare
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
[✓] The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBUTING.md#-commit-message-guidelines
[✓] Tests for the changes have been added (for bug fixes / features)
[ ] Docs have been added / updated (for bug fixes / features)
PR Type
[ ] Bugfix
[✓] Feature / Performance
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:
What is the current behavior?
When bundling an application with server-side rendering, Domino (~560 KB unminified) is bundled into both
polyfills.server.mjs(via@angular/platform-server/init) andmain.server.mjs(via@angular/platform-server).What is the new behavior?
Domino is bundled only once in
polyfills.server.mjsand attached toglobalThis['ɵdomino']. The main server bundle redirects Domino imports to this shared instance.This replaces the redundant bundled copy of Domino in
main.server.mjswithout requiring manual filesystem probing oradditionalContentparameter threading in polyfill options.Does this PR introduce a breaking change?
[ ] Yes
[✓] No