Commit 18757a9
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 e3d55b2 commit 18757a9
5 files changed
Lines changed: 64 additions & 49 deletions
File tree
- packages/angular/build/src
- builders
- application
- unit-test/runners/vitest
- tools/esbuild
- angular
Lines changed: 0 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | 129 | | |
144 | 130 | | |
145 | 131 | | |
| |||
453 | 439 | | |
454 | 440 | | |
455 | 441 | | |
456 | | - | |
457 | 442 | | |
458 | 443 | | |
459 | 444 | | |
| |||
490 | 475 | | |
491 | 476 | | |
492 | 477 | | |
493 | | - | |
494 | 478 | | |
495 | 479 | | |
496 | 480 | | |
| |||
Lines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
259 | 260 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
| 261 | + | |
266 | 262 | | |
267 | 263 | | |
268 | 264 | | |
| |||
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
417 | 432 | | |
418 | 433 | | |
419 | 434 | | |
| |||
557 | 572 | | |
558 | 573 | | |
559 | 574 | | |
| 575 | + | |
560 | 576 | | |
561 | 577 | | |
562 | 578 | | |
| |||
Lines changed: 45 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
443 | 447 | | |
444 | 448 | | |
445 | 449 | | |
| |||
483 | 487 | | |
484 | 488 | | |
485 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
486 | 494 | | |
487 | 495 | | |
488 | 496 | | |
| |||
496 | 504 | | |
497 | 505 | | |
498 | 506 | | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
511 | 524 | | |
512 | | - | |
513 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
514 | 528 | | |
515 | 529 | | |
516 | 530 | | |
| |||
576 | 590 | | |
577 | 591 | | |
578 | 592 | | |
579 | | - | |
580 | | - | |
581 | | - | |
| 593 | + | |
582 | 594 | | |
583 | 595 | | |
584 | 596 | | |
| |||
860 | 872 | | |
861 | 873 | | |
862 | 874 | | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
Lines changed: 0 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | 73 | | |
83 | 74 | | |
84 | 75 | | |
| |||
0 commit comments