Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import { defineConfig } from 'vitest/config';

const [major, minor] = process.versions.node.split('.').map(Number);
const existing = process.env.NODE_OPTIONS || '';
const supportsStripTypes = major > 22 || (major === 22 && minor >= 6);
const stripFlag = major >= 23 ? '--strip-types' : '--experimental-strip-types';
// Node 24+ has type stripping on by default and removed --strip-types from the
// NODE_OPTIONS allowlist, so injecting the flag is both unnecessary and fatal
// (workers refuse to start). Only inject for the Node 22.6+ / Node 23 window
// where the flag is required and accepted.
const needsStripFlag = (major === 22 && minor >= 6) || major === 23;
const stripFlag = major === 23 ? '--strip-types' : '--experimental-strip-types';

export default defineConfig({
resolve: {
Expand All @@ -19,7 +23,7 @@ export default defineConfig({
env: {
NODE_OPTIONS: [
existing,
supportsStripTypes && !existing.includes('--experimental-strip-types') && !existing.includes('--strip-types')
needsStripFlag && !existing.includes('--experimental-strip-types') && !existing.includes('--strip-types')
? stripFlag
: '',
].filter(Boolean).join(' '),
Expand Down
Loading