Skip to content

Commit 9b5a452

Browse files
committed
fix(@angular/build): enhance Vitest resolution for optimal package loading
Align Vitest's module resolution with the development server to ensure consistent behavior. This change configures Vitest to prioritize ESM-optimized package entry points by setting 'es2020', 'module', and 'main' as main fields and 'es2015', 'es2020', and 'module' as conditions during module resolution. This improves compatibility and performance by utilizing modern JavaScript module formats where available.
1 parent 245d464 commit 9b5a452

File tree

1 file changed

+4
-0
lines changed
  • packages/angular/build/src/builders/unit-test/runners/vitest

1 file changed

+4
-0
lines changed

packages/angular/build/src/builders/unit-test/runners/vitest/plugins.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ export async function createVitestConfigPlugin(
124124
noDiscovery: true,
125125
include: options.optimizeDepsInclude,
126126
},
127+
resolve: {
128+
mainFields: ['es2020', 'module', 'main'],
129+
conditions: ['es2015', 'es2020', 'module'],
130+
},
127131
};
128132

129133
const { optimizeDeps, resolve } = config;

0 commit comments

Comments
 (0)