Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for tsimp #410

Merged
merged 1 commit into from
Sep 20, 2024
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,6 @@ yarn.lock

#tap files
.tap/

# tsimp cache
.tsimp/
9 changes: 8 additions & 1 deletion lib/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ Object.defineProperties(runtime, {
return cache.tsx
}
},
tsimp: {
get () {
cache.tsimp ??= checkProcessArgv('tsimp/import')
return cache.tsimp
}
},
supportTypeScript: {
get () {
cache.supportTypeScript ??= (
Expand All @@ -109,7 +115,8 @@ Object.defineProperties(runtime, {
runtime.swc ||
runtime.tsm ||
runtime.tsx ||
runtime.esbuild
runtime.esbuild ||
runtime.tsimp
)
return cache.supportTypeScript
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"typescript:swc-node-register": "node scripts/unit-typescript-swc-node-register.js",
"typescript:tsm": "node scripts/unit-typescript-tsm.js",
"typescript:tsx": "node scripts/unit-typescript-tsx.js",
"typescript:tsimp": "node scripts/unit-typescript-tsimp.js",
"typescript:esbuild": "node scripts/unit-typescript-esbuild.js",
"typescript:vitest": "vitest run",
"typescript:vitest:dev": "vitest",
Expand Down Expand Up @@ -62,9 +63,10 @@
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"tsd": "^0.31.1",
"tsimp": "^2.0.11",
"tsm": "^2.3.0",
"tsx": "^4.15.7",
"typescript": "^5.4.5",
"typescript": "5.5",
"vite": "^5.2.12",
"vitest": "^2.0.3"
},
Expand Down
18 changes: 18 additions & 0 deletions scripts/unit-typescript-tsimp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const { exec } = require('node:child_process')

const args = [
'TSIMP_PROJECT=tsconfig.tsimp.json',
'node',
'--import=tsimp/import',
'test/typescript/basic.ts'
]

const child = exec(args.join(' '), {
shell: true
})

child.stdout.pipe(process.stdout)
child.stderr.pipe(process.stderr)
child.once('close', process.exit)
7 changes: 7 additions & 0 deletions tsconfig.tsimp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"noEmit": true,
"strict": true
},
"include": ["test/typescript/**/*.ts"]
}