Skip to content
Draft
Show file tree
Hide file tree
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
24 changes: 22 additions & 2 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function parseOptions() {
typescript: false,
flow: false,
esbuild: false,
oxc: false,
babel: false,
coverage: getEnvFlag('EXODUS_TEST_COVERAGE'),
coverageEngine: process.platform === 'win32' ? 'node' : 'c8', // c8 or node. TODO: can we use c8 on win?
Expand Down Expand Up @@ -167,6 +168,9 @@ function parseOptions() {
case '--esbuild':
options.esbuild = args[0] instanceof OptionValue ? String(args.shift()) : '*'
break
case '--oxc':
options.oxc = args[0] instanceof OptionValue ? String(args.shift()) : '*'
break
case '--babel':
options.babel = true
break
Expand Down Expand Up @@ -453,6 +457,8 @@ if (options.concurrency) {
options.concurrency = concurrency
}

assert(!options.esbuild || !options.oxc, 'Options --esbuild and --oxc are mutually exclusive')

if (options.esbuild && !options.bundle) {
setEnv('EXODUS_TEST_ESBUILD', options.esbuild)
if (options.loader === '--import') {
Expand All @@ -465,15 +471,29 @@ if (options.esbuild && !options.bundle) {
console.error(`Error: ${engineName} does not support --esbuild option`)
process.exit(1)
}
} else if (options.oxc) {
setEnv('EXODUS_TEST_OXC', options.oxc)
if (options.loader === '--import') {
const optional = options.oxc === '*' ? '' : '.optional'
args.push('--import', import.meta.resolve(`../loader/oxc${optional}.js`))
} else if (options.flagEngine === false) {
// Engine is set via env, --oxc set via flag. Allow but warn
console.warn(`Warning: ${engineName} does not support --oxc option`)
} else {
console.error(`Error: ${engineName} does not support --oxc option`)
process.exit(1)
}
}

if (options.babel) {
assert(!options.esbuild, 'Options --babel and --esbuild are mutually exclusive')
assert(!options.oxc, 'Options --babel and --oxc are mutually exclusive')
args.push('-r', import.meta.resolve('../loader/babel.cjs'))
}

if (options.typescript) {
assert(!options.esbuild, 'Options --typescript and --esbuild are mutually exclusive')
assert(!options.oxc, 'Options --typescript and --oxc are mutually exclusive')
assert(!options.babel, 'Options --typescript and --babel are mutually exclusive')

if (options.ts === 'flag') {
Expand Down Expand Up @@ -552,9 +572,9 @@ if (options.debug.files) {
}

const tsTests = files.filter((file) => /\.[mc]?tsx?$/u.test(file))
const tsSupport = options.ts === 'auto' || options.esbuild || options.typescript || options.babel
const tsSupport = options.ts === 'auto' || options.esbuild || options.oxc || options.typescript || options.babel
if (tsTests.length > 0 && !tsSupport) {
console.error(`Some tests require --typescript or --esbuild flag:\n ${tsTests.join('\n ')}`)
console.error(`Some tests require --typescript, --esbuild or --oxc flag:\n ${tsTests.join('\n ')}`)
process.exit(1)
} else if (!allfiles.some((file) => /\.[cm]?ts$/.test(file)) && options.typescript) {
console.warn(`Flag --typescript has been used, but there were no TypeScript tests found!`)
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"test:typescript": "node ./bin/index.js --jest --typescript tests/typescript.test.ts",
"test:jest": "node ./bin/index.js --jest --esbuild=ts,sum.test.js",
"test:esbuild": "node ./bin/index.js --jest --esbuild",
"test:oxc": "node ./bin/index.js --jest --oxc",
"test:tape": "node ./bin/index.js tests/vendor/tape/test/*.js tests/tape/*.test.*js",
"test:simple": "node ./bin/index.js 'tests/*.test.js'",
"test:pure": "EXODUS_TEST_ENGINE=node:pure npm run test --",
Expand Down Expand Up @@ -184,6 +185,7 @@
"@chalker/queue": "^1.0.1",
"@exodus/replay": "^1.0.0-rc.11",
"@exodus/test-bundler": "1.0.0-rc.17",
"@oxc-node/core": "^0.0.35",
"c8": "^9.1.0",
"expect": "^30.2.0",
"fast-glob": "^3.2.11",
Expand All @@ -196,6 +198,7 @@
"@exodus/eslint-config": "^5.24.0",
"@exodus/prettier": "^1.0.0",
"@jest/globals": "^29.7.0",
"@oxc-node/core": "^0.0.35",
"@types/jest-when": "^3.5.2",
"@types/node": "^24.0.11",
"@typescript-eslint/eslint-plugin": "^7.15.0",
Expand Down Expand Up @@ -223,6 +226,9 @@
"@babel/register": {
"optional": true
},
"@oxc-node/core": {
"optional": true
},
"electron": {
"optional": true
},
Expand Down
217 changes: 217 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading