rolldown-plugin-dts 0.21.4 → 0.21.6
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/filename.mjs +1 -1
- package/dist/{index-C8o_kIRC.d.mts → index-DWPGYc3m.d.mts} +1 -1
- package/dist/index.d.mts +132 -132
- package/dist/index.mjs +63 -51
- package/dist/{tsc-DmkHlcNe.mjs → tsc-Cg6Z_HPb.mjs} +26 -26
- package/dist/tsc-context.d.mts +1 -1
- package/dist/tsc-context.mjs +1 -1
- package/dist/tsc-worker.d.mts +1 -1
- package/dist/tsc-worker.mjs +1 -1
- package/dist/tsc.d.mts +1 -1
- package/dist/tsc.mjs +1 -1
- package/package.json +10 -10
- /package/dist/{context-EuY-ImLj.mjs → context-DoVwxr5H.mjs} +0 -0
- /package/dist/{context-CCPZT79j.d.mts → context-Dt8gPoCq.d.mts} +0 -0
- /package/dist/{filename-Cqnsj8Gp.mjs → filename-DhMOFFZT.mjs} +0 -0
- /package/dist/{resolver-CQnlAxJ7.mjs → resolver-o20sdYK5.mjs} +0 -0
package/dist/filename.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-
|
|
1
|
+
import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-DhMOFFZT.mjs";
|
|
2
2
|
|
|
3
3
|
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn };
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-
|
|
2
|
-
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-
|
|
1
|
+
import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-DhMOFFZT.mjs";
|
|
2
|
+
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-DoVwxr5H.mjs";
|
|
3
3
|
import { createDebug } from "obug";
|
|
4
4
|
import { generate } from "@babel/generator";
|
|
5
5
|
import { parse } from "@babel/parser";
|
|
@@ -122,14 +122,15 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
122
122
|
const appendStmts = [];
|
|
123
123
|
const namespaceStmts = /* @__PURE__ */ new Map();
|
|
124
124
|
for (const [i, stmt] of program.body.entries()) {
|
|
125
|
-
const setStmt = (stmt
|
|
125
|
+
const setStmt = (stmt) => program.body[i] = stmt;
|
|
126
126
|
if (rewriteImportExport(stmt, setStmt, typeOnlyIds)) continue;
|
|
127
127
|
const sideEffect = stmt.type === "TSModuleDeclaration" && stmt.kind !== "namespace";
|
|
128
|
+
if (sideEffect && stmt.id.type === "StringLiteral" && stmt.id.value[0] === ".") this.warn(`\`declare module ${JSON.stringify(stmt.id.value)}\` will be kept as-is in the output. Relative module declaration may cause unexpected issues. Found in ${id}.`);
|
|
128
129
|
if (sideEffect && id.endsWith(".vue.d.ts") && code.slice(stmt.start, stmt.end).includes("__VLS_")) continue;
|
|
129
130
|
const isDefaultExport = stmt.type === "ExportDefaultDeclaration";
|
|
130
131
|
const isExportDecl = isTypeOf(stmt, ["ExportNamedDeclaration", "ExportDefaultDeclaration"]) && !!stmt.declaration;
|
|
131
132
|
const decl = isExportDecl ? stmt.declaration : stmt;
|
|
132
|
-
const setDecl = isExportDecl ? (decl
|
|
133
|
+
const setDecl = isExportDecl ? (decl) => stmt.declaration = decl : setStmt;
|
|
133
134
|
if (decl.type !== "TSDeclareFunction" && !isDeclarationType(decl)) continue;
|
|
134
135
|
if (isTypeOf(decl, [
|
|
135
136
|
"TSEnumDeclaration",
|
|
@@ -140,10 +141,12 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
140
141
|
"VariableDeclaration"
|
|
141
142
|
])) decl.declare = true;
|
|
142
143
|
const bindings = [];
|
|
143
|
-
if (decl.type === "VariableDeclaration") bindings.push(...decl.declarations.map((decl
|
|
144
|
+
if (decl.type === "VariableDeclaration") bindings.push(...decl.declarations.map((decl) => decl.id));
|
|
144
145
|
else if ("id" in decl && decl.id) {
|
|
145
146
|
let binding = decl.id;
|
|
147
|
+
if (binding.type === "TSQualifiedName") binding = getIdFromTSEntityName(binding);
|
|
146
148
|
binding = sideEffect ? t.identifier(`_${getIdentifierIndex("")}`) : binding;
|
|
149
|
+
if (binding.type !== "Identifier") throw new Error(`Unexpected ${binding.type} declaration id`);
|
|
147
150
|
bindings.push(binding);
|
|
148
151
|
} else {
|
|
149
152
|
const binding = t.identifier("export_default");
|
|
@@ -239,8 +242,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
239
242
|
const [declarationIdNode, depsFn, children] = node.declarations[0].init.elements;
|
|
240
243
|
const declarationId = declarationIdNode.value;
|
|
241
244
|
const declaration = getDeclaration(declarationId);
|
|
242
|
-
walkAST(declaration.decl, { enter(node
|
|
243
|
-
|
|
245
|
+
walkAST(declaration.decl, { enter(node) {
|
|
246
|
+
if (node.type === "CommentBlock") return;
|
|
247
|
+
delete node.loc;
|
|
244
248
|
} });
|
|
245
249
|
for (const [i, decl] of node.declarations.entries()) {
|
|
246
250
|
const transformedBinding = {
|
|
@@ -256,8 +260,17 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
256
260
|
for (const originalTypeParam of declaration.params[i].typeParams) originalTypeParam.name = transformedName;
|
|
257
261
|
}
|
|
258
262
|
const transformedDeps = depsFn.body.elements;
|
|
259
|
-
for (const [i, originalDep] of declaration.deps.entries())
|
|
260
|
-
|
|
263
|
+
for (const [i, originalDep] of declaration.deps.entries()) {
|
|
264
|
+
let transformedDep = transformedDeps[i];
|
|
265
|
+
if (transformedDep.type === "UnaryExpression" && transformedDep.operator === "void") transformedDep = {
|
|
266
|
+
...t.identifier("undefined"),
|
|
267
|
+
loc: transformedDep.loc,
|
|
268
|
+
start: transformedDep.start,
|
|
269
|
+
end: transformedDep.end
|
|
270
|
+
};
|
|
271
|
+
if (originalDep.replace) originalDep.replace(transformedDep);
|
|
272
|
+
else Object.assign(originalDep, transformedDep);
|
|
273
|
+
}
|
|
261
274
|
return inheritNodeComments(node, declaration.decl);
|
|
262
275
|
}).filter((node) => !!node);
|
|
263
276
|
if (program.body.length === 0) return "export { };";
|
|
@@ -267,9 +280,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
267
280
|
const preserveComments = commentsMap.get(id);
|
|
268
281
|
if (preserveComments) {
|
|
269
282
|
preserveComments.forEach((c) => {
|
|
270
|
-
const id
|
|
271
|
-
if (commentsValue.has(id
|
|
272
|
-
commentsValue.add(id
|
|
283
|
+
const id = c.type + c.value;
|
|
284
|
+
if (commentsValue.has(id)) return;
|
|
285
|
+
commentsValue.add(id);
|
|
273
286
|
comments.add(c);
|
|
274
287
|
});
|
|
275
288
|
commentsMap.delete(id);
|
|
@@ -280,7 +293,6 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
280
293
|
program.body[0].leadingComments.unshift(...comments);
|
|
281
294
|
}
|
|
282
295
|
const result = generate(file, {
|
|
283
|
-
comments: true,
|
|
284
296
|
sourceMaps: sourcemap,
|
|
285
297
|
sourceFileName: chunk.fileName
|
|
286
298
|
});
|
|
@@ -309,8 +321,8 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
309
321
|
*/
|
|
310
322
|
function collectParams(node) {
|
|
311
323
|
const typeParams = [];
|
|
312
|
-
walkAST(node, { leave(node
|
|
313
|
-
if ("typeParameters" in node
|
|
324
|
+
walkAST(node, { leave(node) {
|
|
325
|
+
if ("typeParameters" in node && node.typeParameters?.type === "TSTypeParameterDeclaration") typeParams.push(...node.typeParameters.params.map((param) => param.name));
|
|
314
326
|
} });
|
|
315
327
|
const paramMap = /* @__PURE__ */ new Map();
|
|
316
328
|
for (const typeParam of typeParams) {
|
|
@@ -319,9 +331,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
319
331
|
if (group) group.push(typeParam);
|
|
320
332
|
else paramMap.set(name, [typeParam]);
|
|
321
333
|
}
|
|
322
|
-
return Array.from(paramMap.entries()).map(([name, typeParams
|
|
334
|
+
return Array.from(paramMap.entries()).map(([name, typeParams]) => ({
|
|
323
335
|
name,
|
|
324
|
-
typeParams
|
|
336
|
+
typeParams
|
|
325
337
|
}));
|
|
326
338
|
}
|
|
327
339
|
function collectDependencies(node, namespaceStmts, children) {
|
|
@@ -329,63 +341,63 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
329
341
|
const seen = /* @__PURE__ */ new Set();
|
|
330
342
|
const inferredStack = [];
|
|
331
343
|
let currentInferred = /* @__PURE__ */ new Set();
|
|
332
|
-
function isInferred(node
|
|
333
|
-
return node
|
|
344
|
+
function isInferred(node) {
|
|
345
|
+
return node.type === "Identifier" && currentInferred.has(node.name);
|
|
334
346
|
}
|
|
335
347
|
walkAST(node, {
|
|
336
|
-
enter(node
|
|
337
|
-
if (node
|
|
338
|
-
const inferred = collectInferredNames(node
|
|
348
|
+
enter(node) {
|
|
349
|
+
if (node.type === "TSConditionalType") {
|
|
350
|
+
const inferred = collectInferredNames(node.extendsType);
|
|
339
351
|
inferredStack.push(inferred);
|
|
340
352
|
}
|
|
341
353
|
},
|
|
342
|
-
leave(node
|
|
343
|
-
if (node
|
|
354
|
+
leave(node, parent) {
|
|
355
|
+
if (node.type === "TSConditionalType") inferredStack.pop();
|
|
344
356
|
else if (parent?.type === "TSConditionalType") {
|
|
345
|
-
const trueBranch = parent.trueType === node
|
|
357
|
+
const trueBranch = parent.trueType === node;
|
|
346
358
|
currentInferred = new Set((trueBranch ? inferredStack : inferredStack.slice(0, -1)).flat());
|
|
347
359
|
} else currentInferred = /* @__PURE__ */ new Set();
|
|
348
|
-
if (node
|
|
349
|
-
for (const specifier of node
|
|
350
|
-
} else if (node
|
|
351
|
-
else if (node
|
|
352
|
-
if (node
|
|
353
|
-
if (node
|
|
360
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
361
|
+
for (const specifier of node.specifiers) if (specifier.type === "ExportSpecifier") addDependency(specifier.local);
|
|
362
|
+
} else if (node.type === "TSInterfaceDeclaration" && node.extends) for (const heritage of node.extends || []) addDependency(heritage.expression);
|
|
363
|
+
else if (node.type === "ClassDeclaration") {
|
|
364
|
+
if (node.superClass) addDependency(node.superClass);
|
|
365
|
+
if (node.implements) for (const implement of node.implements) {
|
|
354
366
|
if (implement.type === "ClassImplements") throw new Error("Unexpected Flow syntax");
|
|
355
367
|
addDependency(implement.expression);
|
|
356
368
|
}
|
|
357
|
-
} else if (isTypeOf(node
|
|
369
|
+
} else if (isTypeOf(node, [
|
|
358
370
|
"ObjectMethod",
|
|
359
371
|
"ObjectProperty",
|
|
360
372
|
"ClassProperty",
|
|
361
373
|
"TSPropertySignature",
|
|
362
374
|
"TSDeclareMethod"
|
|
363
375
|
])) {
|
|
364
|
-
if (node
|
|
365
|
-
if ("value" in node
|
|
366
|
-
} else switch (node
|
|
376
|
+
if (node.computed && isReferenceId(node.key)) addDependency(node.key);
|
|
377
|
+
if ("value" in node && isReferenceId(node.value)) addDependency(node.value);
|
|
378
|
+
} else switch (node.type) {
|
|
367
379
|
case "TSTypeReference":
|
|
368
|
-
addDependency(TSEntityNameToRuntime(node
|
|
380
|
+
addDependency(TSEntityNameToRuntime(node.typeName));
|
|
369
381
|
break;
|
|
370
382
|
case "TSTypeQuery":
|
|
371
|
-
if (seen.has(node
|
|
372
|
-
if (node
|
|
373
|
-
addDependency(TSEntityNameToRuntime(node
|
|
383
|
+
if (seen.has(node.exprName)) return;
|
|
384
|
+
if (node.exprName.type === "TSImportType") break;
|
|
385
|
+
addDependency(TSEntityNameToRuntime(node.exprName));
|
|
374
386
|
break;
|
|
375
387
|
case "TSImportType": {
|
|
376
|
-
seen.add(node
|
|
377
|
-
const { source, qualifier } = node
|
|
378
|
-
addDependency(importNamespace(node
|
|
388
|
+
seen.add(node);
|
|
389
|
+
const { source, qualifier } = node;
|
|
390
|
+
addDependency(importNamespace(node, qualifier, source, namespaceStmts));
|
|
379
391
|
break;
|
|
380
392
|
}
|
|
381
393
|
}
|
|
382
|
-
if (parent && !deps.has(node
|
|
394
|
+
if (parent && !deps.has(node) && isChildSymbol(node, parent)) children.add(node);
|
|
383
395
|
}
|
|
384
396
|
});
|
|
385
397
|
return Array.from(deps);
|
|
386
|
-
function addDependency(node
|
|
387
|
-
if (isThisExpression(node
|
|
388
|
-
deps.add(node
|
|
398
|
+
function addDependency(node) {
|
|
399
|
+
if (isThisExpression(node) || isInferred(node)) return;
|
|
400
|
+
deps.add(node);
|
|
389
401
|
}
|
|
390
402
|
}
|
|
391
403
|
function importNamespace(node, imported, source, namespaceStmts) {
|
|
@@ -422,8 +434,8 @@ function isChildSymbol(node, parent) {
|
|
|
422
434
|
}
|
|
423
435
|
function collectInferredNames(node) {
|
|
424
436
|
const inferred = [];
|
|
425
|
-
walkAST(node, { enter(node
|
|
426
|
-
if (node
|
|
437
|
+
walkAST(node, { enter(node) {
|
|
438
|
+
if (node.type === "TSInferType" && node.typeParameter) inferred.push(node.typeParameter.name.name);
|
|
427
439
|
} });
|
|
428
440
|
return inferred;
|
|
429
441
|
}
|
|
@@ -912,8 +924,8 @@ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = f
|
|
|
912
924
|
else if (typeof tsgo === "object" && tsgo.enabled === false) tsgo = false;
|
|
913
925
|
let resolvedTsconfig;
|
|
914
926
|
if (tsconfig === true || tsconfig == null) {
|
|
915
|
-
const { config, path
|
|
916
|
-
tsconfig = path
|
|
927
|
+
const { config, path } = getTsconfig(cwd) || {};
|
|
928
|
+
tsconfig = path;
|
|
917
929
|
resolvedTsconfig = config;
|
|
918
930
|
} else if (typeof tsconfig === "string") {
|
|
919
931
|
tsconfig = path.resolve(cwd || process.cwd(), tsconfig);
|
|
@@ -1034,7 +1046,7 @@ function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolver, sideEffe
|
|
|
1034
1046
|
async function resolveDtsPath(id, importer, rolldownResolution) {
|
|
1035
1047
|
let dtsPath;
|
|
1036
1048
|
if (resolver === "tsc") {
|
|
1037
|
-
const { tscResolve } = await import("./resolver-
|
|
1049
|
+
const { tscResolve } = await import("./resolver-o20sdYK5.mjs");
|
|
1038
1050
|
dtsPath = tscResolve(id, importer, cwd, tsconfig, tsconfigRaw);
|
|
1039
1051
|
} else dtsPath = baseDtsResolver(id, importer);
|
|
1040
1052
|
debug$1("Using %s for dts import: %O -> %O", resolver, id, dtsPath);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
|
|
2
|
-
import { n as RE_DTS, r as RE_DTS_MAP } from "./filename-
|
|
3
|
-
import { n as globalContext } from "./context-
|
|
2
|
+
import { n as RE_DTS, r as RE_DTS_MAP } from "./filename-DhMOFFZT.mjs";
|
|
3
|
+
import { n as globalContext } from "./context-DoVwxr5H.mjs";
|
|
4
4
|
const {
|
|
5
5
|
createRequire
|
|
6
6
|
} = globalThis.process.getBuiltinModule("node:module");
|
|
@@ -27,12 +27,12 @@ function createFsSystem(files) {
|
|
|
27
27
|
write(message) {
|
|
28
28
|
debug$4(message);
|
|
29
29
|
},
|
|
30
|
-
resolvePath(path
|
|
31
|
-
if (files.has(path
|
|
32
|
-
return ts.sys.resolvePath(path
|
|
30
|
+
resolvePath(path) {
|
|
31
|
+
if (files.has(path)) return path;
|
|
32
|
+
return ts.sys.resolvePath(path);
|
|
33
33
|
},
|
|
34
34
|
directoryExists(directory) {
|
|
35
|
-
if (Array.from(files.keys()).some((path
|
|
35
|
+
if (Array.from(files.keys()).some((path) => path.startsWith(directory))) return true;
|
|
36
36
|
return ts.sys.directoryExists(directory);
|
|
37
37
|
},
|
|
38
38
|
fileExists(fileName) {
|
|
@@ -43,9 +43,9 @@ function createFsSystem(files) {
|
|
|
43
43
|
if (files.has(fileName)) return files.get(fileName);
|
|
44
44
|
return ts.sys.readFile(fileName, ...args);
|
|
45
45
|
},
|
|
46
|
-
writeFile(path
|
|
47
|
-
files.set(path
|
|
48
|
-
ts.sys.writeFile(path
|
|
46
|
+
writeFile(path, data, ...args) {
|
|
47
|
+
files.set(path, data);
|
|
48
|
+
ts.sys.writeFile(path, data, ...args);
|
|
49
49
|
},
|
|
50
50
|
deleteFile(fileName, ...args) {
|
|
51
51
|
files.delete(fileName);
|
|
@@ -56,8 +56,8 @@ function createFsSystem(files) {
|
|
|
56
56
|
function createMemorySystem(files) {
|
|
57
57
|
return {
|
|
58
58
|
...createFsSystem(files),
|
|
59
|
-
writeFile(path
|
|
60
|
-
files.set(path
|
|
59
|
+
writeFile(path, data) {
|
|
60
|
+
files.set(path, data);
|
|
61
61
|
},
|
|
62
62
|
deleteFile(fileName) {
|
|
63
63
|
files.delete(fileName);
|
|
@@ -260,13 +260,13 @@ function loadVueLanguageTools() {
|
|
|
260
260
|
}
|
|
261
261
|
function initVueLanguageTools() {
|
|
262
262
|
const { vue, volarTs: { proxyCreateProgram } } = loadVueLanguageTools();
|
|
263
|
-
const getLanguagePlugin = (ts
|
|
263
|
+
const getLanguagePlugin = (ts, options) => {
|
|
264
264
|
const $rootDir = options.options.$rootDir;
|
|
265
265
|
const $configRaw = options.options.$configRaw;
|
|
266
|
-
const resolver = new vue.CompilerOptionsResolver(ts
|
|
266
|
+
const resolver = new vue.CompilerOptionsResolver(ts, ts.sys.readFile);
|
|
267
267
|
resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
|
|
268
268
|
const vueOptions = resolver.build();
|
|
269
|
-
return vue.createVueLanguagePlugin(ts
|
|
269
|
+
return vue.createVueLanguagePlugin(ts, options.options, vueOptions, (id) => id);
|
|
270
270
|
};
|
|
271
271
|
return {
|
|
272
272
|
proxyCreateProgram,
|
|
@@ -274,35 +274,35 @@ function initVueLanguageTools() {
|
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
function initTsMacro() {
|
|
277
|
-
const debug
|
|
278
|
-
debug
|
|
277
|
+
const debug = createDebug("rolldown-plugin-dts:ts-macro");
|
|
278
|
+
debug("loading ts-macro language tools");
|
|
279
279
|
try {
|
|
280
280
|
const tsMacroPath = __require.resolve("@ts-macro/tsc");
|
|
281
281
|
const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [tsMacroPath] }));
|
|
282
282
|
const tsMacro = __require(__require.resolve("@ts-macro/language-plugin", { paths: [tsMacroPath] }));
|
|
283
283
|
const { getOptions } = __require(__require.resolve("@ts-macro/language-plugin/options", { paths: [tsMacroPath] }));
|
|
284
|
-
const getLanguagePlugin = (ts
|
|
284
|
+
const getLanguagePlugin = (ts, options) => {
|
|
285
285
|
const $rootDir = options.options.$rootDir;
|
|
286
|
-
return tsMacro.getLanguagePlugins(ts
|
|
286
|
+
return tsMacro.getLanguagePlugins(ts, options.options, getOptions(ts, $rootDir))[0];
|
|
287
287
|
};
|
|
288
288
|
return {
|
|
289
289
|
proxyCreateProgram,
|
|
290
290
|
getLanguagePlugin
|
|
291
291
|
};
|
|
292
292
|
} catch (error) {
|
|
293
|
-
debug
|
|
293
|
+
debug("ts-macro language tools not found", error);
|
|
294
294
|
throw new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.");
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
function createProgramFactory(ts
|
|
297
|
+
function createProgramFactory(ts, options) {
|
|
298
298
|
const vueLanguageTools = options.vue ? initVueLanguageTools() : void 0;
|
|
299
299
|
const tsMacroLanguageTools = options.tsMacro ? initTsMacro() : void 0;
|
|
300
300
|
const proxyCreateProgram = vueLanguageTools?.proxyCreateProgram || tsMacroLanguageTools?.proxyCreateProgram;
|
|
301
|
-
if (!proxyCreateProgram) return ts
|
|
302
|
-
return proxyCreateProgram(ts
|
|
301
|
+
if (!proxyCreateProgram) return ts.createProgram;
|
|
302
|
+
return proxyCreateProgram(ts, ts.createProgram, (ts, options) => {
|
|
303
303
|
const languagePlugins = [];
|
|
304
|
-
if (vueLanguageTools) languagePlugins.push(vueLanguageTools.getLanguagePlugin(ts
|
|
305
|
-
if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts
|
|
304
|
+
if (vueLanguageTools) languagePlugins.push(vueLanguageTools.getLanguagePlugin(ts, options));
|
|
305
|
+
if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts, options));
|
|
306
306
|
return { languagePlugins };
|
|
307
307
|
});
|
|
308
308
|
}
|
|
@@ -324,8 +324,8 @@ const defaultCompilerOptions = {
|
|
|
324
324
|
};
|
|
325
325
|
function createOrGetTsModule(options) {
|
|
326
326
|
const { id, entries, context = globalContext } = options;
|
|
327
|
-
const program = context.programs.find((program
|
|
328
|
-
const roots = program
|
|
327
|
+
const program = context.programs.find((program) => {
|
|
328
|
+
const roots = program.getRootFileNames();
|
|
329
329
|
if (entries) return entries.every((entry) => roots.includes(entry));
|
|
330
330
|
return roots.includes(id);
|
|
331
331
|
});
|
package/dist/tsc-context.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as globalContext, i as createContext, n as SourceFileToProjectMap, o as invalidateContextFile, r as TscContext, t as ParsedProject } from "./context-
|
|
1
|
+
import { a as globalContext, i as createContext, n as SourceFileToProjectMap, o as invalidateContextFile, r as TscContext, t as ParsedProject } from "./context-Dt8gPoCq.mjs";
|
|
2
2
|
export { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile };
|
package/dist/tsc-context.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-
|
|
1
|
+
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-DoVwxr5H.mjs";
|
|
2
2
|
|
|
3
3
|
export { createContext, globalContext, invalidateContextFile };
|
package/dist/tsc-worker.d.mts
CHANGED
package/dist/tsc-worker.mjs
CHANGED
package/dist/tsc.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-
|
|
1
|
+
import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-DWPGYc3m.mjs";
|
|
2
2
|
export { TscModule, TscOptions, TscResult, tscEmit };
|
package/dist/tsc.mjs
CHANGED
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.6",
|
|
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,31 +73,31 @@
|
|
|
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
|
-
"@types/node": "^25.0.
|
|
80
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
79
|
+
"@types/node": "^25.0.10",
|
|
80
|
+
"@typescript/native-preview": "7.0.0-dev.20260122.4",
|
|
81
81
|
"@volar/typescript": "^2.4.27",
|
|
82
82
|
"@vue/language-core": "^3.2.2",
|
|
83
83
|
"arktype": "^2.1.29",
|
|
84
84
|
"bumpp": "^10.4.0",
|
|
85
85
|
"diff": "^8.0.3",
|
|
86
86
|
"eslint": "^9.39.2",
|
|
87
|
-
"prettier": "^3.8.
|
|
88
|
-
"rolldown": "^1.0.0-
|
|
87
|
+
"prettier": "^3.8.1",
|
|
88
|
+
"rolldown": "^1.0.0-rc.1",
|
|
89
89
|
"rolldown-plugin-dts-snapshot": "^0.3.2",
|
|
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.
|
|
93
|
+
"tsdown": "^0.20.1",
|
|
94
94
|
"typescript": "^5.9.3",
|
|
95
|
-
"vitest": "^4.0.
|
|
96
|
-
"vue": "^3.5.
|
|
95
|
+
"vitest": "^4.0.18",
|
|
96
|
+
"vue": "^3.5.27",
|
|
97
97
|
"vue-tsc": "^3.2.2"
|
|
98
98
|
},
|
|
99
99
|
"resolutions": {
|
|
100
|
-
"rolldown": "^1.0.0-
|
|
100
|
+
"rolldown": "^1.0.0-rc.1"
|
|
101
101
|
},
|
|
102
102
|
"prettier": "@sxzz/prettier-config",
|
|
103
103
|
"scripts": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|