Skip to content

Commit 5e54ce2

Browse files
committed
🎉 feat: use absolute path to generate declaration file
1 parent f55cf5c commit 5e54ce2

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 1.3.11 - 10 Sep 2025
2+
Improvement:
3+
- type generator: add `compilerOptions`, `tmpRoot` options
4+
5+
Bug fix:
6+
- type generator: use absolute path to generate types
7+
18
# 1.3.10 - 5 Sep 2025
29
Feature:
310
- type generator: accept `.d.ts` to prevent type generation in production

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elysiajs/openapi",
3-
"version": "1.3.10",
3+
"version": "1.3.11",
44
"description": "Plugin for Elysia to auto-generate API documentation",
55
"author": {
66
"name": "saltyAom",

src/gen/index.ts

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ interface OpenAPIGeneratorOptions {
5858
* @default false
5959
*/
6060
debug?: boolean
61+
62+
/**
63+
* compilerOptions
64+
*
65+
* Override tsconfig.json compilerOptions
66+
*/
67+
compilerOptions?: Record<string, any>
68+
69+
/**
70+
* Temporary root
71+
*
72+
* a folder where temporary files are stored
73+
* @default os.tmpdir()/.ElysiaAutoOpenAPI
74+
*
75+
* ! be careful that the folder will be removed after the process ends
76+
*/
77+
tmpRoot?: string
6178
}
6279

6380
/**
@@ -80,12 +97,12 @@ export const fromTypes =
8097
instanceName,
8198
projectRoot = process.cwd(),
8299
overrideOutputPath,
83-
debug = false
100+
debug = false,
101+
compilerOptions,
102+
tmpRoot = join(tmpdir(), '.ElysiaAutoOpenAPI')
84103
}: OpenAPIGeneratorOptions = {}
85104
) =>
86105
() => {
87-
const tmpRoot = join(tmpdir(), '.ElysiaAutoOpenAPI')
88-
89106
try {
90107
if (
91108
!targetFilePath.endsWith('.ts') &&
@@ -128,16 +145,20 @@ export const fromTypes =
128145
join(tmpRoot, 'tsconfig.json'),
129146
`{
130147
${extendsRef}
131-
"compilerOptions": {
132-
"lib": ["ESNext"],
133-
"module": "ESNext",
134-
"noEmit": false,
135-
"declaration": true,
136-
"emitDeclarationOnly": true,
137-
"moduleResolution": "bundler",
138-
"skipLibCheck": true,
139-
"skipDefaultLibCheck": true,
140-
"outDir": "./dist"
148+
"compilerOptions": ${
149+
compilerOptions
150+
? JSON.stringify(compilerOptions)
151+
: `{
152+
"lib": ["ESNext"],
153+
"module": "ESNext",
154+
"noEmit": false,
155+
"declaration": true,
156+
"emitDeclarationOnly": true,
157+
"moduleResolution": "bundler",
158+
"skipLibCheck": true,
159+
"skipDefaultLibCheck": true,
160+
"outDir": "${join(tmpRoot, 'dist')}"
161+
}`
141162
},
142163
"include": ["${src}"]
143164
}`

0 commit comments

Comments
 (0)