Skip to content

Commit

Permalink
Make --typescript an alias for --esbuild, undocument and warn
Browse files Browse the repository at this point in the history
  • Loading branch information
ChALkeR committed Jul 14, 2024
1 parent 3b906dd commit b0f6d71
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ Just use `"test": "exodus-test"`

- `--jest` -- register jest test helpers as global variables, also load `jest.config.*` configuration options

- `--typescript` -- use typescript loader (which also compiles esm to cjs where needed)

- `--esbuild` -- use esbuild loader (currently an alias for `--typescript`)
- `--esbuild` -- use esbuild loader, also enables Typescript support

- `--babel` -- use babel loader (slower than `--esbuild`, makes sense if you have a special config)

Expand Down
10 changes: 6 additions & 4 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function parseOptions() {
options.jest = true
break
case '--typescript':
console.warn('Option --typescript is going to be gone or changed. Use --esbuild instead')
options.typescript = true
options.esbuild = true
break
case '--esbuild':
options.esbuild = true
Expand Down Expand Up @@ -148,7 +150,7 @@ if (options.coverage) {
}
}

if (options.typescript || options.esbuild) {
if (options.esbuild) {
if (major >= 22 || (major === 20 && minor >= 6) || (major === 18 && minor >= 18)) {
assert(resolveImport)
args.push('--import', resolveImport('tsx'))
Expand All @@ -158,7 +160,7 @@ if (options.typescript || options.esbuild) {
}

if (options.babel) {
assert(!options.typescript, 'Options --babel and --typescript are mutually exclusive')
assert(!options.esbuild, 'Options --babel and --esbuild are mutually exclusive')
args.push('-r', resolveRequire('./babel.cjs'))
}

Expand Down Expand Up @@ -267,8 +269,8 @@ if (options.debug.files) {
}

const tsTests = files.filter((file) => /\.[mc]?tsx?$/u.test(file))
if (tsTests.length > 0 && !options.typescript) {
console.error(`Some tests require --typescript flag:\n ${tsTests.join('\n ')}`)
if (tsTests.length > 0 && !options.esbuild) {
console.error(`Some tests require --esbuild flag:\n ${tsTests.join('\n ')}`)
process.exit(1)
} else if (!allfiles.some((file) => file.endsWith('.ts')) && options.typescript) {
console.warn(`Flag --typescript has been used, but there were no TypeScript tests found!`)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"CHANGELOG.md"
],
"scripts": {
"test": "./bin/index.js --jest --typescript",
"test": "./bin/index.js --jest --esbuild",
"test:tape": "./bin/index.js --esbuild '__test__/tape/test/*.js' __test__/tape.test.js",
"coverage": "./bin/index.js --jest --typescript --coverage",
"coverage": "./bin/index.js --jest --esbuild --coverage",
"lint": "prettier --list-different . && eslint .",
"lint:fix": "prettier --write . && eslint --fix ."
},
Expand Down

0 comments on commit b0f6d71

Please sign in to comment.