Skip to content

Commit 7dc6093

Browse files
committed
refactor(@angular/build): deprecate splitting option in unit-test builder
DEPRECATED: The `splitting` option in the unit-test builder is deprecated as it is no longer needed with Vitest 5. Disabling code splitting is no longer necessary with Vitest 5, as the issue where shared-module exports were uninitialized in class-field initializers under JSDOM has been resolved.
1 parent 17dc0f4 commit 7dc6093

2 files changed

Lines changed: 3 additions & 19 deletions

File tree

packages/angular/build/src/builders/unit-test/schema.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"runnerConfig": {
2323
"type": ["string", "boolean"],
24-
"description": "Specifies the configuration file for the selected test runner. If a string is provided, it will be used as the path to the configuration file. If `true`, the builder will search for a default configuration file (e.g., `vitest-base.config.ts` or `karma.conf.js`). If `false`, no external configuration file will be used.\\nFor Vitest, this enables advanced options and the use of custom plugins. Please note that while the file is loaded, the Angular team does not provide direct support for its specific contents or any third-party plugins used within it.",
24+
"description": "Specifies the configuration file for the selected test runner. If a string is provided, it will be used as the path to the configuration file. If `true`, the builder will search for a default configuration file (e.g., `vitest-base.config.mts` or `karma.conf.js`). If `false`, no external configuration file will be used.\\nFor Vitest, this enables advanced options and the use of custom plugins. Please note that while the file is loaded, the Angular team does not provide direct support for its specific contents or any third-party plugins used within it.",
2525
"default": false
2626
},
2727
"browsers": {
@@ -80,7 +80,8 @@
8080
"splitting": {
8181
"type": "boolean",
8282
"description": "Enables code splitting for test execution. When enabled, shared code between test files is split into separate chunks. Issues with live ESM bindings in Node.js environments (such as uninitialized exports or mocking failures) can be resolved by disabling splitting. This option is only available for the Vitest runner.",
83-
"default": true
83+
"default": true,
84+
"x-deprecated": "No longer needed with Vitest 5."
8485
},
8586
"quiet": {
8687
"type": "boolean",

packages/angular/build/src/builders/unit-test/tests/behavior/vitest-shared-chunk-init_spec.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,11 @@ import {
1616

1717
describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
1818
describe('Behavior: "Vitest shared chunk initialization"', () => {
19-
// Regression test for https://github.com/angular/angular-cli/issues/33728.
20-
//
21-
// Without `disableCodeSplitting`, esbuild hoists a module imported by more than one spec
22-
// entry point into a shared chunk behind a lazy `__esm` initializer, and a class-field
23-
// initializer in another chunk reads the exported value as `undefined` under the jsdom
24-
// runner. All four trigger conditions are required and encoded below:
25-
// 1. two spec entry points import the shared module (so it lands in a shared chunk);
26-
// 2. a component in one entry reads the export during class-field initialization;
27-
// 3. that component's spec file contains an `async` test callback (no `await` needed);
28-
// 4. zone.js is in the polyfills (the `setupApplicationTarget` default), which downlevels
29-
// async and makes esbuild emit the spec entry CommonJS-wrapped.
30-
//
31-
// NOTE: the failure this guards against is sensitive to inert content — adding a top-level
32-
// side effect (even a `console.log`) to the shared or importing module below defused it
33-
// during reduction. Mirror https://github.com/jonmarozick/ng-shared-chunk-repro when
34-
// modifying these fixtures.
3519
it('should provide shared-module exports to class-field initializers in async specs', async () => {
3620
setupApplicationTarget(harness);
3721

3822
harness.useTarget('test', {
3923
...BASE_OPTIONS,
40-
splitting: false,
4124
});
4225

4326
// Keep the default project's spec deterministic; a third spec entry that does not touch

0 commit comments

Comments
 (0)