Skip to content

Commit 4e27b9b

Browse files
authored
feat: add support for tsimp (#410)
1 parent 8c7949d commit 4e27b9b

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,6 @@ yarn.lock
150150

151151
#tap files
152152
.tap/
153+
154+
# tsimp cache
155+
.tsimp/

lib/runtime.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ Object.defineProperties(runtime, {
9898
return cache.tsx
9999
}
100100
},
101+
tsimp: {
102+
get () {
103+
cache.tsimp ??= checkProcessArgv('tsimp/import')
104+
return cache.tsimp
105+
}
106+
},
101107
supportTypeScript: {
102108
get () {
103109
cache.supportTypeScript ??= (
@@ -109,7 +115,8 @@ Object.defineProperties(runtime, {
109115
runtime.swc ||
110116
runtime.tsm ||
111117
runtime.tsx ||
112-
runtime.esbuild
118+
runtime.esbuild ||
119+
runtime.tsimp
113120
)
114121
return cache.supportTypeScript
115122
}

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"typescript:swc-node-register": "node scripts/unit-typescript-swc-node-register.js",
1616
"typescript:tsm": "node scripts/unit-typescript-tsm.js",
1717
"typescript:tsx": "node scripts/unit-typescript-tsx.js",
18+
"typescript:tsimp": "node scripts/unit-typescript-tsimp.js",
1819
"typescript:esbuild": "node scripts/unit-typescript-esbuild.js",
1920
"typescript:vitest": "vitest run",
2021
"typescript:vitest:dev": "vitest",
@@ -62,9 +63,10 @@
6263
"ts-node": "^10.9.2",
6364
"ts-node-dev": "^2.0.0",
6465
"tsd": "^0.31.1",
66+
"tsimp": "^2.0.11",
6567
"tsm": "^2.3.0",
6668
"tsx": "^4.15.7",
67-
"typescript": "^5.4.5",
69+
"typescript": "5.5",
6870
"vite": "^5.2.12",
6971
"vitest": "^2.0.3"
7072
},

scripts/unit-typescript-tsimp.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict'
2+
3+
const { exec } = require('node:child_process')
4+
5+
const args = [
6+
'TSIMP_PROJECT=tsconfig.tsimp.json',
7+
'node',
8+
'--import=tsimp/import',
9+
'test/typescript/basic.ts'
10+
]
11+
12+
const child = exec(args.join(' '), {
13+
shell: true
14+
})
15+
16+
child.stdout.pipe(process.stdout)
17+
child.stderr.pipe(process.stderr)
18+
child.once('close', process.exit)

tsconfig.tsimp.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"noEmit": true,
4+
"strict": true
5+
},
6+
"include": ["test/typescript/**/*.ts"]
7+
}

0 commit comments

Comments
 (0)