Skip to content

Commit 2c0b43d

Browse files
committed
feat: Add Bun and Deno to typescript support check
1 parent 688199d commit 2c0b43d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/find-plugins.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ function accumulatePlugin ({ file, type, opts, pluginTree, prefix }) {
145145

146146
function handleTypeScriptSupport (file, language, isHook = false) {
147147
if (language === 'typescript' && !runtime.supportTypeScript) {
148-
throw new Error(`@fastify/autoload cannot import ${isHook ? 'hooks ' : ''}plugin at '${file}'. To fix this error compile TypeScript to JavaScript or use 'ts-node' to run your app.`)
148+
throw new Error(
149+
`@fastify/autoload cannot import ${isHook ? 'hooks ' : ''}plugin at '${file}'. ` +
150+
'To fix this error transpile TypeScript to JavaScript or use an alternative loader or runtime to run your app.'
151+
)
149152
}
150153
}
151154

lib/runtime.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ function checkEnvVariable (name, value) {
3333
: process.env[name] !== undefined
3434
}
3535

36+
function isBun () {
37+
return 'Bun' in globalThis
38+
}
39+
40+
function isDeno () {
41+
return 'Deno' in globalThis
42+
}
43+
3644
const runtime = {}
3745
// use Object.defineProperties to provide lazy load
3846
Object.defineProperties(runtime, {
@@ -102,6 +110,8 @@ Object.defineProperties(runtime, {
102110
get () {
103111
cache.supportTypeScript ??= (
104112
checkEnvVariable('FASTIFY_AUTOLOAD_TYPESCRIPT') ||
113+
isBun() ||
114+
isDeno() ||
105115
runtime.tsNode ||
106116
runtime.vitest ||
107117
runtime.babelNode ||

0 commit comments

Comments
 (0)