Commit ba0a2f0
committed
fix(@angular/build): re-enable code splitting for unit tests
Re-enables esbuild code splitting for unit test builds by removing
`disableCodeSplitting` and resolving the underlying live export binding
issue when chunks are loaded by Vitest under Zone.js (#33728):
1. Ensures test spec files are treated as ES modules by appending
`export {};` in the Angular compiler plugin if absent. In Zone.js
applications, downleveled `async` functions capture module-level `this`
via `__async(this, ...)`. Without an explicit export, esbuild misclassified
spec files as CommonJS and wrapped them in `__commonJS`, which led to lazy
`__esm` initializers for shared dependencies.
2. In the Vitest in-memory provider plugin, eagerly invokes any lazy `__esm`
initializers detected in chunks when loaded for `vite-node`. Because
`vite-node` statically captures exports upon initial chunk evaluation,
eagerly executing the initializers ensures exported values are populated
before consumers read them.
3. Enforces `namedChunks: false` for unit test builds to ensure chunks
consistently match chunk naming patterns.
closes #339481 parent c3cefba commit ba0a2f0
1 file changed
Lines changed: 3 additions & 1 deletion
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
887 | | - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
888 | 890 | | |
0 commit comments