Skip to content

Commit e4afefd

Browse files
committed
fix: remove isolatedDeclaration option
1 parent 535ff08 commit e4afefd

File tree

9 files changed

+40
-112
lines changed

9 files changed

+40
-112
lines changed

.changeset/happy-dots-eat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"elysia-remote-dts": patch
3+
---
4+
5+
remove option for `isolatedDeclaration`

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ dts(entryPoint, options)
6565
| `emitDtsOnly` | `boolean` | `false` | When `true`, the plugin will only emit `.d.ts` files and remove all other chunks. Useful when generating `d.ts` files for CommonJS format as part of a separate build process. |
6666
| `tsconfig` | `string \| boolean` | `"tsconfig.json"` | The path to the `tsconfig.json` file. When set to `false`, any `tsconfig.json` file will be ignored. |
6767
| `compilerOptions` | `object` | `{}` | The `compilerOptions` for the TypeScript compiler. See [TypeScript compiler options](https://www.typescriptlang.org/docs/handbook/compiler-options.html). |
68-
| `isolatedDeclarations` | `boolean \| object` | `false` | When `true`, the plugin will generate `.d.ts` files using `oxc-transform`, which is much faster than the TypeScript compiler. This option is enabled automatically when `isolatedDeclarations` in `compilerOptions` is set to `true`. |
6968
| `sourcemap` | `boolean` | `false` | When `true`, the plugin will generate declaration maps (`.d.ts.map` files) for `.d.ts` files. |
7069
| `resolve` | `boolean \| (string \| RegExp)[]` | `false` | Resolve external types used in `.d.ts` files from `node_modules`. Can be a boolean or an array of strings/RegExp patterns. |
7170
| `resolvePaths` | `boolean` | `false` | When `true`, the plugin will resolve `paths` in `tsconfig.json`. This option is enabled automatically when `paths` is set in `compilerOptions`. |

bun.lock

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"dependencies": {
77
"debug": "^4.4.0",
88
"get-tsconfig": "^4.10.0",
9-
"oxc-transform": "^0.67.0",
109
},
1110
"devDependencies": {
1211
"@biomejs/biome": "1.9.4",
@@ -77,12 +76,6 @@
7776

7877
"@changesets/write": ["@changesets/[email protected]", "", { "dependencies": { "@changesets/types": "^6.1.0", "fs-extra": "^7.0.1", "human-id": "^4.1.1", "prettier": "^2.7.1" } }, "sha512-CdTLvIOPiCNuH71pyDu3rA+Q0n65cmAbXnwWH84rKGiFumFzkmHNT8KHTMEchcxN+Kl8I54xGUhJ7l3E7X396Q=="],
7978

80-
"@emnapi/core": ["@emnapi/[email protected]", "", { "dependencies": { "@emnapi/wasi-threads": "1.0.2", "tslib": "^2.4.0" } }, "sha512-4m62DuCE07lw01soJwPiBGC0nAww0Q+RY70VZ+n49yDIO13yyinhbWCeNnaob0lakDtWQzSdtNWzJeOJt2ma+g=="],
81-
82-
"@emnapi/runtime": ["@emnapi/[email protected]", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-pBPWdu6MLKROBX05wSNKcNb++m5Er+KQ9QkB+WVM+pW2Kx9hoSrVTnu3BdkI5eBLZoKu/J6mW/B6i6bJB2ytXQ=="],
83-
84-
"@emnapi/wasi-threads": ["@emnapi/[email protected]", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-5n3nTJblwRi8LlXkJ9eBzu+kZR8Yxcc7ubakyQTFzPMtIhFpUBRbsnc2Dv88IZDIbCDlBiWrknhB4Lsz7mg6BA=="],
85-
8679
"@esbuild/aix-ppc64": ["@esbuild/[email protected]", "", { "os": "aix", "cpu": "ppc64" }, "sha512-W8bFfPA8DowP8l//sxjJLSLkD8iEjMc7cBVyP+u4cEv9sM7mdUCkgsj+t0n/BWPFtv7WWCN5Yzj0N6FJNUUqBQ=="],
8780

8881
"@esbuild/android-arm": ["@esbuild/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-PuwVXbnP87Tcff5I9ngV0lmiSu40xw1At6i3GsU77U7cjDDB4s0X2cyFuBiDa1SBk9DnvWwnGvVaGBqoFWPb7A=="],
@@ -149,34 +142,12 @@
149142

150143
"@manypkg/get-packages": ["@manypkg/[email protected]", "", { "dependencies": { "@babel/runtime": "^7.5.5", "@changesets/types": "^4.0.1", "@manypkg/find-root": "^1.1.0", "fs-extra": "^8.1.0", "globby": "^11.0.0", "read-yaml-file": "^1.1.0" } }, "sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A=="],
151144

152-
"@napi-rs/wasm-runtime": ["@napi-rs/[email protected]", "", { "dependencies": { "@emnapi/core": "^1.4.0", "@emnapi/runtime": "^1.4.0", "@tybys/wasm-util": "^0.9.0" } }, "sha512-OKRBiajrrxB9ATokgEQoG87Z25c67pCpYcCwmXYX8PBftC9pBfN18gnm/fh1wurSLEKIAt+QRFLFCQISrb66Jg=="],
153-
154145
"@nodelib/fs.scandir": ["@nodelib/[email protected]", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
155146

156147
"@nodelib/fs.stat": ["@nodelib/[email protected]", "", {}, "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="],
157148

158149
"@nodelib/fs.walk": ["@nodelib/[email protected]", "", { "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" } }, "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg=="],
159150

160-
"@oxc-transform/binding-darwin-arm64": ["@oxc-transform/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-P3zBMhpOQceNSys3/ZqvrjuRvcIbVzfGFN/tH34HlVkOjOmfGK1mOWjORsGAZtbgh1muXrF6mQETLzFjfYndXQ=="],
161-
162-
"@oxc-transform/binding-darwin-x64": ["@oxc-transform/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-B52aeo/C3spYHcwFQ4nAbDkwbMKf0K6ncWM8GrVUgGu8PPECLBhjPCW11kPW/lt9FxwrdgVYVzPYlZ6wmJmpEA=="],
163-
164-
"@oxc-transform/binding-linux-arm-gnueabihf": ["@oxc-transform/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-5Ir1eQrC9lvj/rR1TJVGwOR4yLgXTLmfKHIfpVH7GGSQrzK7VMUfHWX+dAsX1VutaeE8puXIqtYvf9cHLw78dw=="],
165-
166-
"@oxc-transform/binding-linux-arm64-gnu": ["@oxc-transform/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-zTqfPET5+hZfJ3/dMqJboKxrpXMXk+j2HVdvX0wVhW2MI7n7hwELl+In6Yu20nXuEyJkNQlWHbNPCUfpM+cBWw=="],
167-
168-
"@oxc-transform/binding-linux-arm64-musl": ["@oxc-transform/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-jzz/ATUhZ8wetb4gm5GwzheZns3Qj1CZ+DIMmD8nBxQXszmTS/fqnAPpgzruyLqkXBUuUfF3pHv5f/UmuHReuQ=="],
169-
170-
"@oxc-transform/binding-linux-x64-gnu": ["@oxc-transform/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-Qy2+tfglJ8yX6guC1EDAnuuzRZIXciXO9UwOewxyiahLxwuTpj/wvvZN3Cb1SA3c14zrwb2TNMZvaXS1/OS5Pg=="],
171-
172-
"@oxc-transform/binding-linux-x64-musl": ["@oxc-transform/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-tHoYgDIRhgvh+/wIrzAk3cUoj/LSSoJAdsZW9XRlaixFW/TF2puxRyaS1hRco0bcKTwotXl/eDYqZmhIfUyGRQ=="],
173-
174-
"@oxc-transform/binding-wasm32-wasi": ["@oxc-transform/[email protected]", "", { "dependencies": { "@napi-rs/wasm-runtime": "^0.2.9" }, "cpu": "none" }, "sha512-ZPT+1HECf7WUnotodIuS8tvSkwaiCdC2DDw8HVRmlerbS6iPYIPKyBCvkSM4RyUx0kljZtB9AciLCkEbwy5/zA=="],
175-
176-
"@oxc-transform/binding-win32-arm64-msvc": ["@oxc-transform/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-+E3lOHCk4EuIk6IjshBAARknAUpgH+gHTtZxCPqK4AWYA+Tls2J6C0FVM48uZ4m3rZpAq8ZszM9JZVAkOaynBQ=="],
177-
178-
"@oxc-transform/binding-win32-x64-msvc": ["@oxc-transform/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-3pIIFb9g5aFrAODTQVJYitq+ONHgDJ4IYk/7pk+jsG6JpKUkURd0auUlxvriO11fFit5hdwy+wIbU4kBvyRUkg=="],
179-
180151
"@pkgjs/parseargs": ["@pkgjs/[email protected]", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="],
181152

182153
"@rollup/rollup-android-arm-eabi": ["@rollup/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-kxz0YeeCrRUHz3zyqvd7n+TVRlNyTifBsmnmNPtk3hQURUyG9eAB+usz6DAwagMusjx/zb3AjvDUvhFGDAexGw=="],
@@ -223,8 +194,6 @@
223194

224195
"@tsconfig/node22": ["@tsconfig/[email protected]", "", {}, "sha512-VkgOa3n6jvs1p+r3DiwBqeEwGAwEvnVCg/hIjiANl5IEcqP3G0u5m8cBJspe1t9qjZRlZ7WFgqq5bJrGdgAKMg=="],
225196

226-
"@tybys/wasm-util": ["@tybys/[email protected]", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw=="],
227-
228197
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.2.11" } }, "sha512-ZLbbI91EmmGwlWTRWuV6J19IUiUC5YQ3TCEuSHI3usIP75kuoA8/0PVF+LTrbEnVc8JIhpElWOxv1ocI1fJBbw=="],
229198

230199
"@types/debug": ["@types/[email protected]", "", { "dependencies": { "@types/ms": "*" } }, "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ=="],
@@ -427,8 +396,6 @@
427396

428397
"outdent": ["[email protected]", "", {}, "sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q=="],
429398

430-
"oxc-transform": ["[email protected]", "", { "optionalDependencies": { "@oxc-transform/binding-darwin-arm64": "0.67.0", "@oxc-transform/binding-darwin-x64": "0.67.0", "@oxc-transform/binding-linux-arm-gnueabihf": "0.67.0", "@oxc-transform/binding-linux-arm64-gnu": "0.67.0", "@oxc-transform/binding-linux-arm64-musl": "0.67.0", "@oxc-transform/binding-linux-x64-gnu": "0.67.0", "@oxc-transform/binding-linux-x64-musl": "0.67.0", "@oxc-transform/binding-wasm32-wasi": "0.67.0", "@oxc-transform/binding-win32-arm64-msvc": "0.67.0", "@oxc-transform/binding-win32-x64-msvc": "0.67.0" } }, "sha512-QXwmpLfNrXZoHgIjEtDEf6lhwmvHouNtstNgg/UveczVIjo8VSzd5h25Ea96PoX9KzReJUY/qYa4QSNkJpZGfA=="],
431-
432399
"p-filter": ["[email protected]", "", { "dependencies": { "p-map": "^2.0.0" } }, "sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw=="],
433400

434401
"p-limit": ["[email protected]", "", { "dependencies": { "p-try": "^2.0.0" } }, "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w=="],
@@ -555,8 +522,6 @@
555522

556523
"ts-interface-checker": ["[email protected]", "", {}, "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA=="],
557524

558-
"tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
559-
560525
"tsup": ["[email protected]", "", { "dependencies": { "bundle-require": "^5.1.0", "cac": "^6.7.14", "chokidar": "^4.0.3", "consola": "^3.4.0", "debug": "^4.4.0", "esbuild": "^0.25.0", "joycon": "^3.1.1", "picocolors": "^1.1.1", "postcss-load-config": "^6.0.1", "resolve-from": "^5.0.0", "rollup": "^4.34.8", "source-map": "0.8.0-beta.0", "sucrase": "^3.35.0", "tinyexec": "^0.3.2", "tinyglobby": "^0.2.11", "tree-kill": "^1.2.2" }, "peerDependencies": { "@microsoft/api-extractor": "^7.36.0", "@swc/core": "^1", "postcss": "^8.4.12", "typescript": ">=4.5.0" }, "optionalPeers": ["@microsoft/api-extractor", "@swc/core", "postcss", "typescript"], "bin": { "tsup": "dist/cli-default.js", "tsup-node": "dist/cli-node.js" } }, "sha512-b+eZbPCjz10fRryaAA7C8xlIHnf8VnsaRqydheLIqwG/Mcpfk8Z5zp3HayX7GaTygkigHl5cBUs+IhcySiIexQ=="],
561526

562527
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="],

example/src/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ import { dts } from 'elysia-remote-dts'
44
const app = new Elysia()
55
.use(dts('./src/index.ts'))
66
.get('/', () => 'Hello Elysia')
7-
.post('/cow', ({ body }) => {
8-
return body.message
9-
}, {
10-
body: t.Object({
11-
message: t.String()
12-
})
13-
})
7+
.post(
8+
'/cow',
9+
({ body }) => {
10+
return body.message
11+
},
12+
{
13+
body: t.Object({
14+
message: t.String(),
15+
}),
16+
}
17+
)
1418
.listen(3000)
1519

1620
export type App = typeof app

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
"access": "public",
2222
"registry": "https://registry.npmjs.org"
2323
},
24-
"files": [
25-
"dist"
26-
],
24+
"files": ["dist"],
2725
"scripts": {
2826
"preinstall": "npx only-allow bun",
2927
"test": "vitest",
@@ -36,8 +34,7 @@
3634
"keywords": [],
3735
"dependencies": {
3836
"debug": "^4.4.0",
39-
"get-tsconfig": "^4.10.0",
40-
"oxc-transform": "^0.67.0"
37+
"get-tsconfig": "^4.10.0"
4138
},
4239
"devDependencies": {
4340
"@biomejs/biome": "1.9.4",

src/generateDts.ts

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'node:path'
22
import Debug from 'debug'
3-
import { isolatedDeclaration as oxcIsolatedDeclaration } from 'oxc-transform'
3+
import type Ts from 'typescript'
44
import { filenameTsToDts } from './filename'
55
import { resolveOptions } from './resolveOptions'
66
import { createOrGetTsModule, initTs, tscEmit } from './tsc'
@@ -41,46 +41,28 @@ export async function generateDts(
4141

4242
// Generate DTS content
4343
let dtsCode = ''
44-
let map: any
4544

46-
if (resolved.isolatedDeclarations) {
47-
const result = oxcIsolatedDeclaration(
48-
absolutePath,
49-
code,
50-
resolved.isolatedDeclarations
51-
)
52-
if (result.errors.length) {
53-
const [error] = result.errors
54-
throw new Error(
55-
`Error generating DTS: ${error.message}\n${error.codeframe || ''}`
56-
)
57-
}
58-
dtsCode = result.code
59-
} else {
60-
// Initialize the TypeScript compiler if not using isolated declarations
61-
if (!resolved.isolatedDeclarations) {
62-
initTs()
63-
}
45+
// Initialize the TypeScript compiler
46+
initTs()
6447

65-
// Create programs array for storing TypeScript programs
66-
const programs: any[] = []
48+
// Create programs array for storing TypeScript programs
49+
const programs: Ts.Program[] = []
6750

68-
// Create or get TypeScript module
69-
const module = createOrGetTsModule(
70-
programs,
71-
resolved.compilerOptions,
72-
absolutePath,
73-
true,
74-
dtsMap
75-
)
51+
// Create or get TypeScript module
52+
const module = createOrGetTsModule(
53+
programs,
54+
resolved.compilerOptions,
55+
absolutePath,
56+
true,
57+
dtsMap
58+
)
7659

77-
// Emit TypeScript declarations
78-
const result = tscEmit(module)
79-
if (result.error) {
80-
throw new Error(`Error generating DTS: ${result.error}`)
81-
}
82-
dtsCode = result.code || ''
60+
// Emit TypeScript declarations
61+
const result = tscEmit(module)
62+
if (result.error) {
63+
throw new Error(`Error generating DTS: ${result.error}`)
8364
}
65+
dtsCode = result.code || ''
8466

8567
return dtsCode
8668
} catch (error) {

src/resolveOptions.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export function resolveOptions({
66
cwd = process.cwd(),
77
tsconfig,
88
compilerOptions = {},
9-
isolatedDeclarations,
109
sourcemap,
1110
dtsInput = false,
1211
emitDtsOnly = false,
@@ -34,23 +33,11 @@ export function resolveOptions({
3433
sourcemap ??= !!compilerOptions.declarationMap
3534
compilerOptions.declarationMap = sourcemap
3635

37-
if (isolatedDeclarations == null) {
38-
isolatedDeclarations = !!compilerOptions?.isolatedDeclarations
39-
}
40-
if (isolatedDeclarations === true) {
41-
isolatedDeclarations = {}
42-
}
43-
if (isolatedDeclarations) {
44-
isolatedDeclarations.stripInternal ??= !!compilerOptions?.stripInternal
45-
// @ts-expect-error omitted in user options
46-
isolatedDeclarations.sourcemap = !!compilerOptions.declarationMap
47-
}
48-
4936
return {
5037
cwd,
5138
tsconfig: typeof tsconfig === 'boolean' ? undefined : tsconfig,
5239
compilerOptions,
53-
isolatedDeclarations,
40+
isolatedDeclarations: false,
5441
sourcemap,
5542
dtsInput,
5643
emitDtsOnly,

src/tsc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ function createTsProgram(
126126

127127
export function tscEmit(module: TscModule): {
128128
code?: string
129-
map?: any
129+
map?: unknown
130130
error?: string
131131
} {
132132
const { program, file } = module
133133
let dtsCode: string | undefined
134-
let map: any
134+
let map: unknown
135135
const { emitSkipped, diagnostics } = program.emit(
136136
file,
137137
(fileName, code) => {

src/types.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { TsConfigJson } from 'get-tsconfig'
2-
import type { IsolatedDeclarationsOptions } from 'oxc-transform'
32

43
export interface Options {
54
/**
@@ -38,16 +37,6 @@ export interface Options {
3837
*/
3938
compilerOptions?: TsConfigJson.CompilerOptions
4039

41-
/**
42-
* When `true`, the plugin will generate `.d.ts` files using `oxc-transform`,
43-
* which is blazingly faster than `typescript` compiler.
44-
*
45-
* This option is enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
46-
*/
47-
isolatedDeclarations?:
48-
| boolean
49-
| Omit<IsolatedDeclarationsOptions, 'sourcemap'>
50-
5140
/**
5241
* When `true`, the plugin will generate declaration maps for `.d.ts` files.
5342
*/
@@ -70,7 +59,7 @@ export type OptionsResolved = Overwrite<
7059
Required<Options>,
7160
{
7261
tsconfig: string | undefined
73-
isolatedDeclarations: IsolatedDeclarationsOptions | false
62+
isolatedDeclarations: false
7463
}
7564
>
7665

0 commit comments

Comments
 (0)