Skip to content

Commit

Permalink
feat: add support for tsimp (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuft2 authored Sep 20, 2024
1 parent 8c7949d commit 4e27b9b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
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"]
}

0 comments on commit 4e27b9b

Please sign in to comment.