rolldown-plugin-dts 0.21.3 → 0.21.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts
CHANGED
|
@@ -5,185 +5,185 @@ import { Plugin } from "rolldown";
|
|
|
5
5
|
//#region src/options.d.ts
|
|
6
6
|
interface GeneralOptions {
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
* The directory in which the plugin will search for the `tsconfig.json` file.
|
|
9
|
+
*/
|
|
10
10
|
cwd?: string;
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
* Set to `true` if your entry files are `.d.ts` files instead of `.ts` files.
|
|
13
|
+
*
|
|
14
|
+
* When enabled, the plugin will skip generating a `.d.ts` file for the entry point.
|
|
15
|
+
*/
|
|
16
16
|
dtsInput?: boolean;
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
* If `true`, the plugin will emit only `.d.ts` files and remove all other output chunks.
|
|
19
|
+
*
|
|
20
|
+
* This is especially useful when generating `.d.ts` files for the CommonJS format as part of a separate build step.
|
|
21
|
+
*/
|
|
22
22
|
emitDtsOnly?: boolean;
|
|
23
23
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
* The path to the `tsconfig.json` file.
|
|
25
|
+
*
|
|
26
|
+
* If set to `false`, the plugin will ignore any `tsconfig.json` file.
|
|
27
|
+
* You can still specify `compilerOptions` directly in the options.
|
|
28
|
+
*
|
|
29
|
+
* @default 'tsconfig.json'
|
|
30
|
+
*/
|
|
31
31
|
tsconfig?: string | boolean;
|
|
32
32
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
* Pass a raw `tsconfig.json` object directly to the plugin.
|
|
34
|
+
*
|
|
35
|
+
* @see https://www.typescriptlang.org/tsconfig
|
|
36
|
+
*/
|
|
37
37
|
tsconfigRaw?: Omit<TsConfigJson, "compilerOptions">;
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
* Override the `compilerOptions` specified in `tsconfig.json`.
|
|
40
|
+
*
|
|
41
|
+
* @see https://www.typescriptlang.org/tsconfig/#compilerOptions
|
|
42
|
+
*/
|
|
43
43
|
compilerOptions?: TsConfigJson.CompilerOptions;
|
|
44
44
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
* If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
|
|
46
|
+
*/
|
|
47
47
|
sourcemap?: boolean;
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
* Specifies a resolver to resolve type definitions, especially for `node_modules`.
|
|
50
|
+
*
|
|
51
|
+
* - `'oxc'`: Uses Oxc's module resolution, which is faster and more efficient.
|
|
52
|
+
* - `'tsc'`: Uses TypeScript's native module resolution, which may be more compatible with complex setups, but slower.
|
|
53
|
+
*
|
|
54
|
+
* @default 'oxc'
|
|
55
|
+
*/
|
|
56
56
|
resolver?: "oxc" | "tsc";
|
|
57
57
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
* Determines how the default export is emitted.
|
|
59
|
+
*
|
|
60
|
+
* If set to `true`, and you are only exporting a single item using `export default ...`,
|
|
61
|
+
* the output will use `export = ...` instead of the standard ES module syntax.
|
|
62
|
+
* This is useful for compatibility with CommonJS.
|
|
63
|
+
*/
|
|
64
64
|
cjsDefault?: boolean;
|
|
65
65
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
* Indicates whether the generated `.d.ts` files have side effects.
|
|
67
|
+
* - If set to `true`, Rolldown will treat the `.d.ts` files as having side effects during tree-shaking.
|
|
68
|
+
* - If set to `false`, Rolldown may consider the `.d.ts` files as side-effect-free, potentially removing them if they are not imported.
|
|
69
|
+
*
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
72
|
sideEffects?: boolean;
|
|
73
73
|
}
|
|
74
74
|
interface TscOptions {
|
|
75
75
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
* Build mode for the TypeScript compiler:
|
|
77
|
+
*
|
|
78
|
+
* - If `true`, the plugin will use [`tsc -b`](https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript) to build the project and all referenced projects before emitting `.d.ts` files.
|
|
79
|
+
* - If `false`, the plugin will use [`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) to emit `.d.ts` files without building referenced projects.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
83
|
build?: boolean;
|
|
84
84
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
85
|
+
* If your tsconfig.json has
|
|
86
|
+
* [`references`](https://www.typescriptlang.org/tsconfig/#references) option,
|
|
87
|
+
* `rolldown-plugin-dts` will use [`tsc
|
|
88
|
+
* -b`](https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript)
|
|
89
|
+
* to build the project and all referenced projects before emitting `.d.ts`
|
|
90
|
+
* files.
|
|
91
|
+
*
|
|
92
|
+
* In such case, if this option is `true`, `rolldown-plugin-dts` will write
|
|
93
|
+
* down all built files into your disk, including
|
|
94
|
+
* [`.tsbuildinfo`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
|
|
95
|
+
* and other built files. This is equivalent to running `tsc -b` in your
|
|
96
|
+
* project.
|
|
97
|
+
*
|
|
98
|
+
* Otherwise, if this option is `false`, `rolldown-plugin-dts` will write
|
|
99
|
+
* built files only into memory and leave a small footprint in your disk.
|
|
100
|
+
*
|
|
101
|
+
* Enabling this option will decrease the build time by caching previous build
|
|
102
|
+
* results. This is helpful when you have a large project with multiple
|
|
103
|
+
* referenced projects.
|
|
104
|
+
*
|
|
105
|
+
* By default, `incremental` is `true` if your tsconfig has
|
|
106
|
+
* [`incremental`](https://www.typescriptlang.org/tsconfig/#incremental) or
|
|
107
|
+
* [`tsBuildInfoFile`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
|
|
108
|
+
* enabled.
|
|
109
|
+
*
|
|
110
|
+
* This option is only used when {@link Options.oxc} is
|
|
111
|
+
* `false`.
|
|
112
|
+
*/
|
|
113
113
|
incremental?: boolean;
|
|
114
114
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
* If `true`, the plugin will generate `.d.ts` files using `vue-tsc`.
|
|
116
|
+
*/
|
|
117
117
|
vue?: boolean;
|
|
118
118
|
/**
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
* If `true`, the plugin will generate `.d.ts` files using `@ts-macro/tsc`.
|
|
120
|
+
*/
|
|
121
121
|
tsMacro?: boolean;
|
|
122
122
|
/**
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
* If `true`, the plugin will launch a separate process for `tsc` or `vue-tsc`.
|
|
124
|
+
* This enables processing multiple projects in parallel.
|
|
125
|
+
*/
|
|
126
126
|
parallel?: boolean;
|
|
127
127
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
* If `true`, the plugin will prepare all files listed in `tsconfig.json` for `tsc` or `vue-tsc`.
|
|
129
|
+
*
|
|
130
|
+
* This is especially useful when you have a single `tsconfig.json` for multiple projects in a monorepo.
|
|
131
|
+
*/
|
|
132
132
|
eager?: boolean;
|
|
133
133
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
* If `true`, the plugin will create a new isolated context for each build,
|
|
135
|
+
* ensuring that previously generated `.d.ts` code and caches are not reused.
|
|
136
|
+
*
|
|
137
|
+
* By default, the plugin may reuse internal caches or incremental build artifacts
|
|
138
|
+
* to speed up repeated builds. Enabling this option forces a clean context,
|
|
139
|
+
* guaranteeing that all type definitions are generated from scratch.
|
|
140
|
+
*
|
|
141
|
+
* @default false
|
|
142
|
+
*/
|
|
143
143
|
newContext?: boolean;
|
|
144
144
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
* If `true`, the plugin will emit `.d.ts` files for `.js` files as well.
|
|
146
|
+
* This is useful when you want to generate type definitions for JavaScript files with JSDoc comments.
|
|
147
|
+
*
|
|
148
|
+
* Enabled by default when `allowJs` in compilerOptions is `true`.
|
|
149
|
+
* This option is only used when {@link Options.oxc} is
|
|
150
|
+
* `false`.
|
|
151
|
+
*/
|
|
152
152
|
emitJs?: boolean;
|
|
153
153
|
}
|
|
154
154
|
interface Options extends GeneralOptions, TscOptions {
|
|
155
155
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
* If `true`, the plugin will generate `.d.ts` files using Oxc,
|
|
157
|
+
* which is significantly faster than the TypeScript compiler.
|
|
158
|
+
*
|
|
159
|
+
* This option is automatically enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
|
|
160
|
+
*/
|
|
161
161
|
oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
|
|
162
162
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
163
|
+
* **[Experimental]** Enables DTS generation using `tsgo`.
|
|
164
|
+
*
|
|
165
|
+
* To use this option, make sure `@typescript/native-preview` is installed as a dependency,
|
|
166
|
+
* or provide a custom path to the `tsgo` binary using the `path` option.
|
|
167
|
+
*
|
|
168
|
+
* **Note:** This option is not yet recommended for production environments.
|
|
169
|
+
* `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
|
|
170
|
+
*
|
|
171
|
+
*
|
|
172
|
+
* ```ts
|
|
173
|
+
* // Use tsgo from `@typescript/native-preview` dependency
|
|
174
|
+
* tsgo: true
|
|
175
|
+
*
|
|
176
|
+
* // Use custom tsgo path (e.g., managed by Nix)
|
|
177
|
+
* tsgo: { path: '/path/to/tsgo' }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
180
|
tsgo?: boolean | TsgoOptions;
|
|
181
181
|
}
|
|
182
182
|
interface TsgoOptions {
|
|
183
183
|
enabled?: boolean;
|
|
184
184
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
* Custom path to the `tsgo` binary.
|
|
186
|
+
*/
|
|
187
187
|
path?: string;
|
|
188
188
|
}
|
|
189
189
|
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
package/dist/index.mjs
CHANGED
|
@@ -110,7 +110,8 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
110
110
|
const file = parse(code, {
|
|
111
111
|
plugins: [["typescript", { dts: true }]],
|
|
112
112
|
sourceType: "module",
|
|
113
|
-
errorRecovery: true
|
|
113
|
+
errorRecovery: true,
|
|
114
|
+
createParenthesizedExpressions: true
|
|
114
115
|
});
|
|
115
116
|
const { program, comments } = file;
|
|
116
117
|
const typeOnlyIds = [];
|
|
@@ -239,6 +240,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
239
240
|
const declarationId = declarationIdNode.value;
|
|
240
241
|
const declaration = getDeclaration(declarationId);
|
|
241
242
|
walkAST(declaration.decl, { enter(node$1) {
|
|
243
|
+
if (node$1.type === "CommentBlock") return;
|
|
242
244
|
delete node$1.loc;
|
|
243
245
|
} });
|
|
244
246
|
for (const [i, decl] of node.declarations.entries()) {
|
|
@@ -279,7 +281,6 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
279
281
|
program.body[0].leadingComments.unshift(...comments);
|
|
280
282
|
}
|
|
281
283
|
const result = generate(file, {
|
|
282
|
-
comments: true,
|
|
283
284
|
sourceMaps: sourcemap,
|
|
284
285
|
sourceFileName: chunk.fileName
|
|
285
286
|
});
|
|
@@ -1033,7 +1034,7 @@ function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolver, sideEffe
|
|
|
1033
1034
|
async function resolveDtsPath(id, importer, rolldownResolution) {
|
|
1034
1035
|
let dtsPath;
|
|
1035
1036
|
if (resolver === "tsc") {
|
|
1036
|
-
const { tscResolve } = await import("./resolver-
|
|
1037
|
+
const { tscResolve } = await import("./resolver-CQnlAxJ7.mjs");
|
|
1037
1038
|
dtsPath = tscResolve(id, importer, cwd, tsconfig, tsconfigRaw);
|
|
1038
1039
|
} else dtsPath = baseDtsResolver(id, importer);
|
|
1039
1040
|
debug$1("Using %s for dts import: %O -> %O", resolver, id, dtsPath);
|
|
@@ -8,7 +8,10 @@ const debug = createDebug("rolldown-plugin-dts:tsc-resolver");
|
|
|
8
8
|
function tscResolve(id, importer, cwd, tsconfig, tsconfigRaw, reference) {
|
|
9
9
|
const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
|
|
10
10
|
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, ts.sys, baseDir);
|
|
11
|
-
const resolved = ts.bundlerModuleNameResolver(id, importer,
|
|
11
|
+
const resolved = ts.bundlerModuleNameResolver(id, importer, {
|
|
12
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
13
|
+
...parsedConfig.options
|
|
14
|
+
}, ts.sys, void 0, reference);
|
|
12
15
|
debug(`tsc resolving id "%s" from "%s" -> %O`, id, importer, resolved.resolvedModule);
|
|
13
16
|
return resolved.resolvedModule?.resolvedFileName;
|
|
14
17
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-dts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.21.
|
|
4
|
+
"version": "0.21.5",
|
|
5
5
|
"description": "A Rolldown plugin to generate and bundle dts files.",
|
|
6
6
|
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@jridgewell/source-map": "^0.3.11",
|
|
76
|
-
"@sxzz/eslint-config": "^7.
|
|
76
|
+
"@sxzz/eslint-config": "^7.5.0",
|
|
77
77
|
"@sxzz/prettier-config": "^2.2.6",
|
|
78
78
|
"@sxzz/test-utils": "^0.5.15",
|
|
79
79
|
"@types/node": "^25.0.9",
|
|
80
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
80
|
+
"@typescript/native-preview": "7.0.0-dev.20260120.1",
|
|
81
81
|
"@volar/typescript": "^2.4.27",
|
|
82
82
|
"@vue/language-core": "^3.2.2",
|
|
83
83
|
"arktype": "^2.1.29",
|
|
@@ -90,10 +90,10 @@
|
|
|
90
90
|
"rolldown-plugin-require-cjs": "^0.3.3",
|
|
91
91
|
"rollup-plugin-dts": "^6.3.0",
|
|
92
92
|
"tinyglobby": "^0.2.15",
|
|
93
|
-
"tsdown": "^0.20.0-beta.
|
|
93
|
+
"tsdown": "^0.20.0-beta.4",
|
|
94
94
|
"typescript": "^5.9.3",
|
|
95
95
|
"vitest": "^4.0.17",
|
|
96
|
-
"vue": "^3.5.
|
|
96
|
+
"vue": "^3.5.27",
|
|
97
97
|
"vue-tsc": "^3.2.2"
|
|
98
98
|
},
|
|
99
99
|
"resolutions": {
|