René's URL Explorer Experiment


Title: unit-test builder: "sideEffects": false elides statically-referenced barrel modules, component reads as undefined in TestBed · Issue #33910 · angular/angular-cli · GitHub

Open Graph Title: unit-test builder: "sideEffects": false elides statically-referenced barrel modules, component reads as undefined in TestBed · Issue #33910 · angular/angular-cli

X Title: unit-test builder: "sideEffects": false elides statically-referenced barrel modules, component reads as undefined in TestBed · Issue #33910 · angular/angular-cli

Description: Which @angular/* package(s) are the source of the bug? build Is this a regression? Yes, this behaviour used to work in version 21.2.19 Description In a multi-entry-point library built with ng-packagr, @angular/build:unit-test (Vitest + j...

Open Graph Description: Which @angular/* package(s) are the source of the bug? build Is this a regression? Yes, this behaviour used to work in version 21.2.19 Description In a multi-entry-point library built with ng-packa...

X Description: Which @angular/* package(s) are the source of the bug? build Is this a regression? Yes, this behaviour used to work in version 21.2.19 Description In a multi-entry-point library built with ng-packa...

Opengraph URL: https://github.com/angular/angular-cli/issues/33910

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"unit-test builder: \"sideEffects\": false elides statically-referenced barrel modules, component reads as undefined in TestBed","articleBody":"# Which @angular/* package(s) are the source of the bug?\n\nbuild\n\n# Is this a regression?\n\nYes, this behaviour used to work in version 21.2.19\n\n# Description\n\nIn a multi-entry-point library built with ng-packagr, `@angular/build:unit-test` (Vitest + jsdom) elides module bodies from the primary entry point's `export *` barrel graph when the library's `package.json` declares `\"sideEffects\": false`. The namespace re-export accessors for those modules survive and return `undefined`.\n\nWhen one of the dropped exports is a standalone component referenced from a **retained** `imports: [...]` array literal of another component, `TestBed.configureTestingModule` throws:\n\n```\nTypeError: Cannot read properties of undefined (reading 'ɵcmp')\n  at getComponentDef        (core/testing/src/test_bed_compiler.ts:1169)\n  at isStandaloneComponent  (core/testing/src/test_bed_compiler.ts:1162)\n  at queueTypesFromModulesArrayRecur\n  at TestBedCompiler.queueTypesFromModulesArray\n  at TestBedCompiler.configureTestingModule\n```\n\nDropping a module whose export is statically referenced from a retained array literal looks incorrect regardless of `sideEffects`, which is a module-level assertion about *import-for-side-effect* semantics — not a licence to remove a module that is still statically reachable.\n\nIn our library (761 barrel exports across 4 entry points) this fails 36 specs in 3 files, all in one secondary entry point. On Angular 21.2.19 the identical suite is 389/389 green.\n\n## Not a duplicate of #33728\n\n[#33728](https://github.com/angular/angular-cli/issues/33728) describes the same *symptom* (an export from a shared chunk reading as `undefined` under the jsdom runner) and was fixed by [#33729](https://github.com/angular/angular-cli/pull/33729) \"disable code splitting for unit test builds\", released in v22.1.5.\n\nThat fix is **installed and active** here and the failure still reproduces. Verified in the installed package:\n\n- `src/builders/unit-test/runners/vitest/build-options.js:238` sets `disableCodeSplitting: true`\n- honoured at `src/tools/esbuild/application-code-bundle.js:55-58` (`buildOptions.splitting = false`)\n\nSo this is a distinct cause: not cross-chunk lazy initialisers, but whole-module elision driven by `sideEffects`.\n\n# Please provide a link to a minimal reproduction of the bug\n\nUnable to share the affected codebase. Reproduction recipe below — it is deterministic and the toggle is a single field.\n\n**Setup**\n\n1. `ng new repro --no-standalone=false` then `ng generate library lib`, `@angular/build` >= 22.1.5, TypeScript 6.0.3, Node 22.\n2. Add `\"sideEffects\": false` to `projects/lib/package.json`.\n3. In the **primary** entry, create a standalone `FooComponent` and export it through a **multi-level** barrel: `public-api.ts` → `export * from './lib/components/public-api-components'` → `export * from './foo/foo.component'`. At least two levels of `export *` matter; a single flat barrel did not reproduce for us.\n4. Add a **secondary** entry point (`projects/lib/sub/` with its own `ng-package.json` and `public-api.ts`), mapped in the workspace `tsconfig.json` `paths` to its **source** `public-api.ts`, alongside `\"@lib\": [\"./projects/lib/src/public-api.ts\"]`.\n5. In the secondary entry, create a standalone `BarComponent` with `imports: [FooComponent]`, importing it as `import {FooComponent} from '@lib'`.\n6. Give `BarComponent` a spec doing `TestBed.configureTestingModule({imports: [BarComponent]})`.\n7. Configure a test target with `@angular/build:unit-test`, `buildTarget` pointing at the library build, and `include` covering the secondary entry's specs. **Run the whole suite, not a single file** — see below.\n\n**Expected:** spec passes.\n**Actual:** `TypeError: Cannot read properties of undefined (reading 'ɵcmp')`.\n\n**Toggle:** change `projects/lib/package.json` to `\"sideEffects\": true` (or a glob matching the source tree, e.g. `[\"./src/**\", \"./*/src/**\"]`) → passes. Change it back → fails. Deterministic in both directions.\n\n## Diagnostics that pin the mechanism\n\nThese are the observations that distinguish elision from TDZ, resolution failure, or interop snapshotting:\n\n1. **The module body never runs.** Injecting an unconditional `(globalThis as any).__RAN = true` at the top of an affected module leaves `__RAN` `undefined` at runtime, while a control module in the same barrel has its marker set. A module containing an unconditional global assignment can only be removed if it is declared side-effect-free.\n2. **Not TDZ.** On `import * as barrel from '@lib'`, the affected names are present as **ACCESSOR** property descriptors and still return `undefined` after both a microtask and a macrotask tick.\n3. **Not duplicate module identity.** `directImport === barrel.Foo` is `true`.\n4. **Only classes are affected in practice.** Plain functions exported from the same barrel in the same import statement resolve correctly; the value read as `undefined` is the component class. In our failing component, `ɵcmp.dependencies` was `[\"UNDEFINED\", \"TranslatePipe\"]` — the third-party pipe resolved, the barrel-imported component did not.\n5. **Whole-suite dependent.** Running the affected spec alone via `--include` passes; only the full multi-file run drops the module. The set of `undefined` exports also changes with import order — consistent with per-entry retention analysis rather than a fixed graph defect.\n6. **Not specific to one entry point.** A barrel probe placed in a different, CommonJS-free secondary entry returns the *identical* set of `undefined` exports. Whether a given spec fails depends on which barrel modules that entry's retention set happens to keep.\n\n# Please provide the exception or error you saw\n\n```\nTypeError: Cannot read properties of undefined (reading 'ɵcmp')\n    at getComponentDef (../packages/core/testing/src/test_bed_compiler.ts:1169:24)\n    at isStandaloneComponent (../packages/core/testing/src/test_bed_compiler.ts:1162:14)\n    at queueTypesFromModulesArrayRecur (../packages/core/testing/src/test_bed_compiler.ts:847:23)\n    at TestBedCompiler.queueTypesFromModulesArray (../packages/core/testing/src/test_bed_compiler.ts:861:4)\n    at TestBedCompiler.configureTestingModule (../packages/core/testing/src/test_bed_compiler.ts:226:11)\n    at TestBedImpl.configureTestingModule (../packages/core/testing/src/test_bed.ts:594:18)\n```\n\n# Please provide the environment you discovered this bug in (run: ng version)\n\n```\nAngular CLI: 22.1.5\nNode: 22.23.1\nPackage Manager: npm 10.x\nOS: linux x64\n\nAngular: 22.1.3\n... animations, cdk, common, compiler, compiler-cli, core, forms,\n    platform-browser, router\n\nPackage                         Version\n---------------------------------------------------------\n@angular/build                  22.1.5\n@angular/cli                    22.1.5\n@angular-devkit/build-angular   22.1.3\nng-packagr                      22.1.1\ntypescript                      6.0.3\nvitest                          (via @angular/build:unit-test)\n```\n\n# Anything else?\n\nWorkaround that keeps published tree-shaking intact: instead of `\"sideEffects\": false`, use globs that match only the **workspace source** tree and nothing in the build output, e.g.\n\n```json\n\"sideEffects\": [\"./src/**\", \"./*/src/**\"]\n```\n\nng-packagr emits `fesm2022/*.mjs` plus per-entry `package.json` stubs, so these globs match zero emitted files. The published package therefore keeps effective side-effect-free semantics for consumers, while the workspace source — which is what the unit-test build reads through tsconfig `paths` — is treated as impure.\n\nRelated but distinct: [#33467](https://github.com/angular/angular-cli/issues/33467) (unit-test builder resolves `include` relative to `sourceRoot`, also a multi-entry-point blind spot) and [#33893](https://github.com/angular/angular-cli/issues/33893) (`sideEffects: false` interacting with optimizer pure annotations inside published FESMs — statement-level rather than whole-module).\n","author":{"url":"https://github.com/PatVandyke","@type":"Person","name":"PatVandyke"},"datePublished":"2026-08-24T15:33:49Z","url":"https://github.com/angular/angular-cli/issues/33910"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b36aaa94-5d29-5fab-69eb-993305525425
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id953E:5D487:115555E:16FE84C:6B01E84D
html-safe-nonce1e669d8d2b46b8e6d6774bba296dd2e5e9b8e5acb2b160f5fac5369399c391f1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTNFOjVENDg3OjExNTU1NUU6MTZGRTg0Qzo2QjAxRTg0RCIsInZpc2l0b3JfaWQiOiI3Mjc5MjA2MTIwODk4NTUzOTMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacb708c6ecd7508798b71596ddcb65a7952a796196bf757e67f345d954b7a339d6
hovercard-subject-tagissue:5236588936
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/33910/issue_layout
twitter:imagehttps://opengraph.githubassets.com/14969eba1f7d56d6f85a7d61607de1911f11ce87bc94ca7929889143cf06494f/angular/angular-cli/issues/33910
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/14969eba1f7d56d6f85a7d61607de1911f11ce87bc94ca7929889143cf06494f/angular/angular-cli/issues/33910
og:image:altWhich @angular/* package(s) are the source of the bug? build Is this a regression? Yes, this behaviour used to work in version 21.2.19 Description In a multi-entry-point library built with ng-packa...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamePatVandyke
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
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
disable-turbofalse
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
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/33910#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F33910
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%2Fissues%2F33910
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/33910
Reloadhttps://github.com/angular/angular-cli/issues/33910
Reloadhttps://github.com/angular/angular-cli/issues/33910
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
https://github.com/angular/angular-cli
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33910
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33910
#33917https://github.com/angular/angular-cli/pull/33917
unit-test builder: "sideEffects": false elides statically-referenced barrel modules, component reads as undefined in TestBedhttps://github.com/angular/angular-cli/issues/33910#top
#33917https://github.com/angular/angular-cli/pull/33917
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
needsTriagehttps://github.com/angular/angular-cli/milestone/11
https://github.com/PatVandyke
PatVandykehttps://github.com/PatVandyke
on Aug 24, 2026https://github.com/angular/angular-cli/issues/33910#issue-5236588936
#33728https://github.com/angular/angular-cli/issues/33728
#33728https://github.com/angular/angular-cli/issues/33728
#33729https://github.com/angular/angular-cli/pull/33729
#33467https://github.com/angular/angular-cli/issues/33467
#33893https://github.com/angular/angular-cli/issues/33893
angular-robothttps://github.com/apps/angular-robot
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
on Aug 24, 2026https://github.com/angular/angular-cli/issues/33910#event-29923092315
angular-robothttps://github.com/apps/angular-robot
needsTriagehttps://github.com/angular/angular-cli/milestone/11
on Aug 24, 2026https://github.com/angular/angular-cli/issues/33910#event-29923094710
alan-agius4https://github.com/alan-agius4
on Aug 25, 2026https://github.com/angular/angular-cli/issues/33910#event-29980326740
fix(@angular/build): ignore side-effect annotations in unit test buildshttps://github.com/alan-agius4/angular-cli/commit/9f3351843b3a9087492bdfbf4377c57414e1e26c
https://docs.github.com/articles/closing-issues-via-commit-messages
9f33518https://github.com/alan-agius4/angular-cli/commit/9f3351843b3a9087492bdfbf4377c57414e1e26c
alan-agius4https://github.com/alan-agius4
completedhttps://github.com/angular/angular-cli/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#33917https://github.com/angular/angular-cli/pull/33917
on Aug 25, 2026https://github.com/angular/angular-cli/issues/33910#event-29983317336
alan-agius4https://github.com/alan-agius4
on Aug 25, 2026https://github.com/angular/angular-cli/issues/33910#event-29983320818
fix(@angular/build): ignore side-effect annotations in unit test buildshttps://github.com/angular/angular-cli/commit/3f132eaa97b95e16c58b8095c2566e3c78190446
https://docs.github.com/articles/closing-issues-via-commit-messages
3f132eahttps://github.com/angular/angular-cli/commit/3f132eaa97b95e16c58b8095c2566e3c78190446
clydinhttps://github.com/clydin
on Aug 25, 2026https://github.com/angular/angular-cli/issues/33910#event-29983821299
fix(@angular/build): ignore side-effect annotations in unit test buildshttps://github.com/clydin/angular-cli/commit/4d0be683b780a9a1629dc8f9cddad49153bddabf
https://docs.github.com/articles/closing-issues-via-commit-messages
4d0be68https://github.com/clydin/angular-cli/commit/4d0be683b780a9a1629dc8f9cddad49153bddabf
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Oct 20, 2026https://github.com/angular/angular-cli/issues/33910#issuecomment-6280319572
automatic conversation locking policyhttps://github.com/angular/angular/blob/f0fbced1c55bc8b8ed9df01cea99df42f3e7eae3/contributing-docs/auto-issue-locking.md
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Oct 20, 2026https://github.com/angular/angular-cli/issues/33910#event-33697343016
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular-cli/issues/33910
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33910
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
needsTriageNo due datehttps://github.com/angular/angular-cli/milestone/11
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.