Repository navigation
Commit d6f37b9
committed
fix(@angular/build): allow top-level await in the unit test bundle
The Vitest runner generates a virtual `angular:test-bed-init` module for the test bundle. When
Zone.js is resolvable but is not one of the project's polyfills, that module imports
`zone.js/testing` behind a top-level await, so that the import is skipped by a project which never
loads Zone.js.
That bundle is compiled against the targets derived from the project's Browserslist configuration,
and esbuild has no downleveled form for top-level await. A project which targets a browser released
before the syntax was available therefore fails to build its tests with `Top-level await is not
available in the configured target environment`, before the runtime guard in the generated module
can run.
Browserslist describes the browsers an application is deployed to. A test bundle is never deployed:
it is loaded by the test runner's module runner, or by a browser the runner launches, and every
browser Angular supports has had top-level await since 2021. The unit-test builder now marks the
feature as supported through an internal option, which applies to the test bundle alone and leaves
application builds bound to their configured targets.
Related to #333241 parent 5b7f0a5 commit d6f37b9
5 files changed
Lines changed: 78 additions & 2 deletions
File tree
- packages/angular/build/src
- builders
- application
- unit-test
- runners/vitest
- tests/behavior
- tools/esbuild
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
142 | 159 | | |
143 | 160 | | |
144 | 161 | | |
| |||
463 | 480 | | |
464 | 481 | | |
465 | 482 | | |
| 483 | + | |
466 | 484 | | |
467 | 485 | | |
468 | 486 | | |
| |||
500 | 518 | | |
501 | 519 | | |
502 | 520 | | |
| 521 | + | |
503 | 522 | | |
504 | 523 | | |
505 | 524 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
281 | 284 | | |
282 | 285 | | |
283 | 286 | | |
| |||
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
197 | 198 | | |
198 | 199 | | |
199 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
200 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
201 | 208 | | |
202 | 209 | | |
203 | 210 | | |
| |||
0 commit comments