René's URL Explorer Experiment


Title: fix(@angular/build): disable code splitting for unit test builds by jonmarozick · Pull Request #33729 · angular/angular-cli · GitHub

Open Graph Title: fix(@angular/build): disable code splitting for unit test builds by jonmarozick · Pull Request #33729 · angular/angular-cli

X Title: fix(@angular/build): disable code splitting for unit test builds by jonmarozick · Pull Request #33729 · angular/angular-cli

Description: Fixes #33728 PR Checklist Please check to confirm your PR fulfills the following requirements: 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) — unit-test/tests/behavior/vitest-shared-chunk-init_spec.ts; see "Other information" for how the fixture was validated red/green. Docs have been added / updated (for bug fixes / features) — N/A: the new option is internal-only and not exposed in the builder schema. PR Type What kind of change does this PR introduce? Bugfix What is the current behavior? Issue Number: #33728 Under @angular/build:unit-test with the default (jsdom) runner, an export from a module that code splitting hoisted into a shared chunk can be observed as undefined by an importing chunk — a component reading an exported const in a class-field initializer fails with TypeError: Cannot read properties of undefined (reading 'map'), in a test that never touches the runner's own API. The emitted bundles are valid ESM and the same specs pass in browser mode, so the defect is in how the Node-side module-runner path evaluates the split output, not in the bundles. Every spec file is its own entry point, so splitting hoists any module reached from more than one spec into a shared chunk behind lazy __esm initializers; importing chunks then read the export as a live ESM binding, which that path does not reliably preserve at class-field-initialization time. The full analysis — including the exact four-condition trigger set (shared chunk + cross-chunk field read + an async test callback + zone.js polyfills) isolated by single-variable toggles — is in #33728, with a minimal reproduction at https://github.com/jonmarozick/ng-shared-chunk-repro (npm install && npm test: expected 2 passed, actual 1 failed). The failure only appears once a project has more than one spec file, because a single entry point inlines everything and never splits — so a suite can pass for a long time and then break when a second spec file is added. The impact can also be silent: in a larger project on the same setup, jsdom reported 108 of 216 tests (three spec files never loaded) in half the wall-clock of browser mode. What is the new behavior? esbuild code splitting is disabled for the unit-test build only, through a new internal option (disableCodeSplitting) alongside the existing internal test-only options. Test bundles are never downloaded by a browser, so splitting has nothing to optimize here. Three small changes: application/options.ts — declare the internal option and pass it through normalizeOptions. esbuild/application-code-bundle.ts — honour it in createBrowserCodeBundleOptions, following the existing buildOptions.splitting = false precedent used for the polyfills bundle. unit-test/runners/vitest/build-options.ts — set it for the Vitest runner's build. With the change, the minimal reproduction passes (2/2) and no shared chunks are emitted for test builds. Application builds are untouched. Does this PR introduce a breaking change? No Cost: shared modules are duplicated into each spec bundle. Measured on a real 105-spec-file project via --dump-virtual-files: output files total size chunks wall splitting on 169 1.21 MB 57 30s splitting off 112 6.93 MB 0 28s Total output grows ~5.7×; test run time was unchanged. If the extra memory is a concern for very large suites, gating the option on the runner being jsdom (rather than all Vitest builds) would narrow it, since browser mode does not exhibit the bug — happy to adjust. Other information Verification. Verified by applying the equivalent change to an installed 21.2.19 @angular/build (building the CLI from source with Bazel was not available on this machine), so CI should be treated as the authoritative run: check before after minimal reproduction (jsdom) 1 failed / 1 passed 2 passed real 105-spec-file project, browser mode 1018 passed 1018 passed ng build (application build, flag unset) ok ok, still splits Regression test. unit-test/tests/behavior/vitest-shared-chunk-init_spec.ts encodes the issue's four trigger conditions: a shared const imported by two spec entries (shared chunk), a component reading it in a class-field initializer, an async test callback in that component's spec (no await needed), and zone.js in the polyfills (the setupApplicationTarget default). Earlier fixture attempts passed without the fix because their test callbacks were synchronous — zone forces async downleveling, the spec then imports the __async helper, and esbuild emits that spec entry CommonJS-wrapped with the component module behind a lazy __esm initializer, which is the shape in which the cross-chunk read fails. Since Bazel wasn't runnable on my machine, the fixture's exact file contents were validated against an installed 21.2.19 @angular/build in a fresh ng new workspace: unpatched, the container spec fails with the issue's TypeError (1 failed / 2 passed); with this change applied, all pass and no chunk-*.js is emitted. Please treat the CI run of the harness test as authoritative. One caveat encoded as a comment in the test: the failure is sensitive to inert content (a top-level console.log in either module defuses it), so the fixtures intentionally mirror the reproduction byte-for-byte rather than a paraphrase. 🤖 Generated with Claude Code

Open Graph Description: Fixes #33728 PR Checklist Please check to confirm your PR fulfills the following requirements: The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBU...

X Description: Fixes #33728 PR Checklist Please check to confirm your PR fulfills the following requirements: The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBU...

Opengraph URL: https://github.com/angular/angular-cli/pull/33729

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6b653d1e-b030-c352-ce97-c3d6e6ab31fe
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9DC8:20AA01:3A541EA:4A14E7D:6B01E852
html-safe-nonce93960fe5610d1e8a1976ed241000a8a25b989aa05f34dfea97f290d43c22e6f2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REM4OjIwQUEwMTozQTU0MUVBOjRBMTRFN0Q6NkIwMUU4NTIiLCJ2aXNpdG9yX2lkIjoiNDA4MDA5ODQwMzMyODA1OTQ3NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace201b51a1d71180e00768a99aef4b41caca150ab73ecf14ea84eeb60986bd215
hovercard-subject-tagpull_request:4189558222
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/angular/angular-cli/pull/33729/files
twitter:imagehttps://avatars.githubusercontent.com/u/7092843?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/7092843?s=400&v=4
og:image:altFixes #33728 PR Checklist Please check to confirm your PR fulfills the following requirements: The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBU...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/angular/angular-cli/pull/33729/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fpull%2F33729%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fpull%2F33729%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/pull/33729/files
Reloadhttps://github.com/angular/angular-cli/pull/33729/files
Reloadhttps://github.com/angular/angular-cli/pull/33729/files
angularhttps://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Codehttps://github.com/angular/angular-cli
Issues198 (198)https://github.com/angular/angular-cli/issues
Pull requests23 (23)https://github.com/angular/angular-cli/pulls
Actionshttps://github.com/angular/angular-cli/actions
Security and quality8 (8)https://github.com/angular/angular-cli/security
Insightshttps://github.com/angular/angular-cli/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fangular%2Fangular-cli%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fangular%2Fangular-cli%2Fissues%2Fnew%2Fchoose
dgp1130https://github.com/dgp1130
angular:mainhttps://github.com/angular/angular-cli/tree/main
jonmarozick:fix/unit-test-shared-chunk-inithttps://github.com/jonmarozick/angular-cli/tree/fix/unit-test-shared-chunk-init
Conversation 5 https://github.com/angular/angular-cli/pull/33729
Commits 1 https://github.com/angular/angular-cli/pull/33729/commits
Checks 41 https://github.com/angular/angular-cli/pull/33729/checks
Files changed https://github.com/angular/angular-cli/pull/33729/files
Please reload this pagehttps://github.com/angular/angular-cli/pull/33729/files
fix(@angular/build): disable code splitting for unit test builds https://github.com/angular/angular-cli/pull/33729/files#top
Show all changes 1 commit https://github.com/angular/angular-cli/pull/33729/files
746b351 fix(@angular/build): disable code splitting for unit test builds jonmarozick Aug 2, 2026 https://github.com/angular/angular-cli/pull/33729/commits/746b3516996465f55cc558feda82a8dde23fae00
Clear filters https://github.com/angular/angular-cli/pull/33729/files
Please reload this pagehttps://github.com/angular/angular-cli/pull/33729/files
Please reload this pagehttps://github.com/angular/angular-cli/pull/33729/files
options.ts https://github.com/angular/angular-cli/pull/33729/files#diff-c31d390b8683db112fcc30e2ee984d893bdce6bd8e6d7d70c43ecc410a626a3d
build-options.ts https://github.com/angular/angular-cli/pull/33729/files#diff-4f4a6414086e1d6fa99280e3e080d31435105983ba42d64f602e5166d935db5d
vitest-shared-chunk-init_spec.ts https://github.com/angular/angular-cli/pull/33729/files#diff-3bdccb7da522ccdbaf3821f56a960260c3347003c4cc2ba0addc147d9bc34eac
application-code-bundle.ts https://github.com/angular/angular-cli/pull/33729/files#diff-c92828b292a980ac9ce4a0e3fc1d4ed69c93c9488d7222741b30bc653be7dde2
packages/angular/build/src/builders/application/options.tshttps://github.com/angular/angular-cli/pull/33729/files#diff-c31d390b8683db112fcc30e2ee984d893bdce6bd8e6d7d70c43ecc410a626a3d
View file https://github.com/jonmarozick/angular-cli/blob/746b3516996465f55cc558feda82a8dde23fae00/packages/angular/build/src/builders/application/options.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/angular/angular-cli/pull/33729/{{ revealButtonHref }}
https://github.com/angular/angular-cli/pull/33729/files#diff-c31d390b8683db112fcc30e2ee984d893bdce6bd8e6d7d70c43ecc410a626a3d
https://github.com/angular/angular-cli/pull/33729/files#diff-c31d390b8683db112fcc30e2ee984d893bdce6bd8e6d7d70c43ecc410a626a3d
https://github.com/angular/angular-cli/pull/33729/files#diff-c31d390b8683db112fcc30e2ee984d893bdce6bd8e6d7d70c43ecc410a626a3d
https://github.com/angular/angular-cli/pull/33729/files#diff-c31d390b8683db112fcc30e2ee984d893bdce6bd8e6d7d70c43ecc410a626a3d
https://github.com/angular/angular-cli/pull/33729/files#diff-c31d390b8683db112fcc30e2ee984d893bdce6bd8e6d7d70c43ecc410a626a3d
https://github.com/angular/angular-cli/pull/33729/files#diff-c31d390b8683db112fcc30e2ee984d893bdce6bd8e6d7d70c43ecc410a626a3d
packages/angular/build/src/builders/unit-test/runners/vitest/build-options.tshttps://github.com/angular/angular-cli/pull/33729/files#diff-4f4a6414086e1d6fa99280e3e080d31435105983ba42d64f602e5166d935db5d
View file https://github.com/jonmarozick/angular-cli/blob/746b3516996465f55cc558feda82a8dde23fae00/packages/angular/build/src/builders/unit-test/runners/vitest/build-options.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/angular/angular-cli/pull/33729/{{ revealButtonHref }}
https://github.com/angular/angular-cli/pull/33729/files#diff-4f4a6414086e1d6fa99280e3e080d31435105983ba42d64f602e5166d935db5d
https://github.com/angular/angular-cli/pull/33729/files#diff-4f4a6414086e1d6fa99280e3e080d31435105983ba42d64f602e5166d935db5d
...ages/angular/build/src/builders/unit-test/tests/behavior/vitest-shared-chunk-init_spec.tshttps://github.com/angular/angular-cli/pull/33729/files#diff-3bdccb7da522ccdbaf3821f56a960260c3347003c4cc2ba0addc147d9bc34eac
View file https://github.com/jonmarozick/angular-cli/blob/746b3516996465f55cc558feda82a8dde23fae00/packages/angular/build/src/builders/unit-test/tests/behavior/vitest-shared-chunk-init_spec.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/angular/angular-cli/pull/33729/{{ revealButtonHref }}
packages/angular/build/src/tools/esbuild/application-code-bundle.tshttps://github.com/angular/angular-cli/pull/33729/files#diff-c92828b292a980ac9ce4a0e3fc1d4ed69c93c9488d7222741b30bc653be7dde2
View file https://github.com/jonmarozick/angular-cli/blob/746b3516996465f55cc558feda82a8dde23fae00/packages/angular/build/src/tools/esbuild/application-code-bundle.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/angular/angular-cli/pull/33729/{{ revealButtonHref }}
https://github.com/angular/angular-cli/pull/33729/files#diff-c92828b292a980ac9ce4a0e3fc1d4ed69c93c9488d7222741b30bc653be7dde2
https://github.com/angular/angular-cli/pull/33729/files#diff-c92828b292a980ac9ce4a0e3fc1d4ed69c93c9488d7222741b30bc653be7dde2
Please reload this pagehttps://github.com/angular/angular-cli/pull/33729/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.