Repository navigation
fix(@angular/build): enable code splitting for vitest browser tests - #33949
Conversation
cfaa501 to
2c03d17
Compare
2c03d17 to
e3d55b2
Compare
3dd7aa1 to
c3cefba
Compare
There was a problem hiding this comment.
Code Review
This pull request removes the disableCodeSplitting option and resolves ESM binding issues in Vitest/Vite SSR runs. It does this by eagerly invoking __esm initializers in chunk/bundle outputs within the Vitest plugin, and by introducing ensureTestFileEsm in the Angular compiler plugin to append export {}; to test spec files lacking export statements so they are treated as ES modules. The feedback suggests making ensureTestFileEsm idempotent by checking if the file already contains import or export statements before appending export {}; to prevent duplicate appends.
18757a9 to
15f4dfc
Compare
Enables code splitting for Vitest browser tests while keeping it disabled for Node-based tests (JSDOM/Happy-DOM). Vitest's Node-based module loading emulation (vite-node) is not fully spec compliant and lacks live ESM bindings across chunk boundaries, which can cause uninitialized exports and break mocking. In browser tests, however, the real browser adheres to the ECMAScript spec, so code splitting can be safely enabled there.
15f4dfc to
0635ef4
Compare
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Enables code splitting for Vitest browser tests while keeping it disabled for Node-based tests (JSDOM/Happy-DOM).
Vitest's Node-based module loading emulation (
vite-node) is not fully spec compliant and lacks live ESM bindings across chunk boundaries, which can cause uninitialized exports and break mocking. In browser tests, however, the real browser adheres to the ECMAScript spec, so code splitting can be safely enabled there.