Skip to content

Commit

Permalink
fix: use jiti on non-node runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 11, 2024
1 parent 66c8241 commit f260c11
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ export async function detectLoader(cache: boolean | null, isTsFile: boolean): Pr
}

async function tsxOrJiti() {
if (!nodeVersionNumbers)
return 'tsx'

/**
* tsx is supported in Node.js 18.19.0+ and 20.8.0+
* Otherwise we fallback to jiti
*
* @see https://nodejs.org/api/module.html#moduleregisterspecifier-parenturl-options
*/
if (nodeVersionNumbers[0] < 18
if (
!nodeVersionNumbers
|| nodeVersionNumbers[0] < 18
|| (nodeVersionNumbers[0] === 18 && nodeVersionNumbers[1] < 19)
|| (nodeVersionNumbers[0] === 20 && nodeVersionNumbers[1] < 8))
|| (nodeVersionNumbers[0] === 20 && nodeVersionNumbers[1] < 8)
)
return 'jiti'

return 'tsx'
Expand Down

0 comments on commit f260c11

Please sign in to comment.