rolldown-plugin-dts 0.14.1 → 0.14.3
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/README.md +9 -0
- package/dist/{filename-TbnZq0n4.d.ts → filename-4MoswV50.d.ts} +2 -2
- package/dist/{filename-Dpr2dKWZ.js → filename-Dz6Li3gj.js} +3 -3
- package/dist/filename.d.ts +2 -2
- package/dist/filename.js +2 -2
- package/dist/index.d.ts +14 -5
- package/dist/index.js +15 -9
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -158,6 +158,15 @@ guaranteeing that all type definitions are generated from scratch.
|
|
|
158
158
|
|
|
159
159
|
---
|
|
160
160
|
|
|
161
|
+
### emitJs
|
|
162
|
+
|
|
163
|
+
If `true`, the plugin will emit `.d.ts` files for `.js` files as well.
|
|
164
|
+
This is useful when you want to generate type definitions for JavaScript files with JSDoc comments.
|
|
165
|
+
|
|
166
|
+
Enabled by default when `allowJs` in compilerOptions is `true`.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
161
170
|
### tsgo
|
|
162
171
|
|
|
163
172
|
**[Experimental]** Enables DTS generation using [`tsgo`](https://github.com/microsoft/typescript-go).
|
|
@@ -7,8 +7,8 @@ declare const RE_NODE_MODULES: RegExp;
|
|
|
7
7
|
declare const RE_CSS: RegExp;
|
|
8
8
|
declare const RE_VUE: RegExp;
|
|
9
9
|
declare function filename_js_to_dts(id: string): string;
|
|
10
|
-
declare function
|
|
10
|
+
declare function filename_to_dts(id: string): string;
|
|
11
11
|
declare function filename_dts_to(id: string, ext: "js" | "ts"): string;
|
|
12
12
|
declare function isRelative(id: string): boolean;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts,
|
|
14
|
+
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, isRelative };
|
|
@@ -11,8 +11,8 @@ const RE_VUE = /\.vue$/;
|
|
|
11
11
|
function filename_js_to_dts(id) {
|
|
12
12
|
return id.replace(RE_JS, ".d.$1ts");
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return id.replace(RE_VUE, ".vue.ts").replace(RE_TS, ".d.$1ts");
|
|
14
|
+
function filename_to_dts(id) {
|
|
15
|
+
return id.replace(RE_VUE, ".vue.ts").replace(RE_TS, ".d.$1ts").replace(RE_JS, ".d.$1ts");
|
|
16
16
|
}
|
|
17
17
|
function filename_dts_to(id, ext) {
|
|
18
18
|
return id.replace(RE_DTS, `.$1${ext}`);
|
|
@@ -22,4 +22,4 @@ function isRelative(id) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
|
-
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts,
|
|
25
|
+
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, isRelative };
|
package/dist/filename.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts,
|
|
2
|
-
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts,
|
|
1
|
+
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, isRelative } from "./filename-4MoswV50.js";
|
|
2
|
+
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, isRelative };
|
package/dist/filename.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts,
|
|
1
|
+
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, isRelative } from "./filename-Dz6Li3gj.js";
|
|
2
2
|
|
|
3
|
-
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts,
|
|
3
|
+
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, isRelative };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE } from "./filename-
|
|
1
|
+
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE } from "./filename-4MoswV50.js";
|
|
2
2
|
import { TscContext, createContext } from "./index-B4kTNEjT.js";
|
|
3
3
|
import { IsolatedDeclarationsOptions } from "rolldown/experimental";
|
|
4
4
|
import { TsConfigJson } from "get-tsconfig";
|
|
@@ -120,9 +120,16 @@ interface Options {
|
|
|
120
120
|
* to speed up repeated builds. Enabling this option forces a clean context,
|
|
121
121
|
* guaranteeing that all type definitions are generated from scratch.
|
|
122
122
|
*
|
|
123
|
-
*
|
|
123
|
+
* @default false
|
|
124
124
|
*/
|
|
125
125
|
newContext?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* If `true`, the plugin will emit `.d.ts` files for `.js` files as well.
|
|
128
|
+
* This is useful when you want to generate type definitions for JavaScript files with JSDoc comments.
|
|
129
|
+
*
|
|
130
|
+
* Enabled by default when `allowJs` in compilerOptions is `true`.
|
|
131
|
+
*/
|
|
132
|
+
emitJs?: boolean;
|
|
126
133
|
}
|
|
127
134
|
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
128
135
|
type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
|
|
@@ -145,7 +152,8 @@ declare function resolveOptions({
|
|
|
145
152
|
parallel,
|
|
146
153
|
eager,
|
|
147
154
|
tsgo,
|
|
148
|
-
newContext
|
|
155
|
+
newContext,
|
|
156
|
+
emitJs
|
|
149
157
|
}: Options): OptionsResolved;
|
|
150
158
|
//#endregion
|
|
151
159
|
//#region src/fake-js.d.ts
|
|
@@ -166,8 +174,9 @@ declare function createGeneratePlugin({
|
|
|
166
174
|
parallel,
|
|
167
175
|
eager,
|
|
168
176
|
tsgo,
|
|
169
|
-
newContext
|
|
170
|
-
|
|
177
|
+
newContext,
|
|
178
|
+
emitJs
|
|
179
|
+
}: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "incremental" | "isolatedDeclarations" | "emitDtsOnly" | "vue" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs">): Plugin;
|
|
171
180
|
//#endregion
|
|
172
181
|
//#region src/index.d.ts
|
|
173
182
|
declare function dts(options?: Options): Plugin[];
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts,
|
|
1
|
+
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts } from "./filename-Dz6Li3gj.js";
|
|
2
2
|
import { createContext } from "./tsc-Czx4mPt7.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import Debug from "debug";
|
|
@@ -310,7 +310,7 @@ function createFakeJsPlugin({ dtsInput, sourcemap }) {
|
|
|
310
310
|
const elements = [
|
|
311
311
|
t.numericLiteral(0),
|
|
312
312
|
...deps.map((dep) => t.arrowFunctionExpression([], dep)),
|
|
313
|
-
...sideEffect ? [t.callExpression(t.identifier("sideEffect"), [])] : []
|
|
313
|
+
...sideEffect ? [t.callExpression(t.identifier("sideEffect"), [bindings[0]])] : []
|
|
314
314
|
];
|
|
315
315
|
const runtime = t.arrayExpression(elements);
|
|
316
316
|
if (decl !== stmt) {
|
|
@@ -640,7 +640,7 @@ const spawnAsync = (...args) => new Promise((resolve, reject) => {
|
|
|
640
640
|
child.on("close", () => resolve());
|
|
641
641
|
child.on("error", (error) => reject(error));
|
|
642
642
|
});
|
|
643
|
-
function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, isolatedDeclarations, emitDtsOnly, vue, parallel, eager, tsgo, newContext }) {
|
|
643
|
+
function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, isolatedDeclarations, emitDtsOnly, vue, parallel, eager, tsgo, newContext, emitJs }) {
|
|
644
644
|
const dtsMap = /* @__PURE__ */ new Map();
|
|
645
645
|
/**
|
|
646
646
|
* A map of input id to output file name
|
|
@@ -701,13 +701,17 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, isolate
|
|
|
701
701
|
transform: {
|
|
702
702
|
order: "pre",
|
|
703
703
|
filter: { id: {
|
|
704
|
-
include: [
|
|
704
|
+
include: [
|
|
705
|
+
RE_TS,
|
|
706
|
+
RE_VUE,
|
|
707
|
+
...emitJs ? [RE_JS] : []
|
|
708
|
+
],
|
|
705
709
|
exclude: [RE_DTS, RE_NODE_MODULES]
|
|
706
710
|
} },
|
|
707
711
|
handler(code, id) {
|
|
708
712
|
const mod = this.getModuleInfo(id);
|
|
709
713
|
const isEntry = !!mod?.isEntry;
|
|
710
|
-
const dtsId =
|
|
714
|
+
const dtsId = filename_to_dts(id);
|
|
711
715
|
dtsMap.set(dtsId, {
|
|
712
716
|
code,
|
|
713
717
|
id,
|
|
@@ -738,7 +742,7 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, isolate
|
|
|
738
742
|
debug$1("generate dts %s from %s", dtsId, id);
|
|
739
743
|
if (tsgo) {
|
|
740
744
|
if (RE_VUE.test(id)) throw new Error("tsgo does not support Vue files.");
|
|
741
|
-
const dtsPath = path.resolve(tsgoDist, path.relative(path.resolve(cwd),
|
|
745
|
+
const dtsPath = path.resolve(tsgoDist, path.relative(path.resolve(cwd), filename_to_dts(id)));
|
|
742
746
|
if (existsSync(dtsPath)) dtsCode = await readFile(dtsPath, "utf8");
|
|
743
747
|
else {
|
|
744
748
|
debug$1("[tsgo]", dtsPath, "is missing");
|
|
@@ -822,7 +826,7 @@ async function runTsgo(root, tsconfig) {
|
|
|
822
826
|
//#endregion
|
|
823
827
|
//#region src/options.ts
|
|
824
828
|
let warnedTsgo = false;
|
|
825
|
-
function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, compilerOptions = {}, tsconfigRaw: overriddenTsconfigRaw = {}, isolatedDeclarations, sourcemap, dtsInput = false, emitDtsOnly = false, resolve = false, vue = false, parallel = false, eager = false, tsgo = false, newContext = false }) {
|
|
829
|
+
function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, compilerOptions = {}, tsconfigRaw: overriddenTsconfigRaw = {}, isolatedDeclarations, sourcemap, dtsInput = false, emitDtsOnly = false, resolve = false, vue = false, parallel = false, eager = false, tsgo = false, newContext = false, emitJs }) {
|
|
826
830
|
let resolvedTsconfig;
|
|
827
831
|
if (tsconfig === true || tsconfig == null) {
|
|
828
832
|
const { config, path: path$1 } = getTsconfig(cwd) || {};
|
|
@@ -850,6 +854,7 @@ function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, co
|
|
|
850
854
|
isolatedDeclarations.stripInternal ??= !!compilerOptions?.stripInternal;
|
|
851
855
|
isolatedDeclarations.sourcemap = !!compilerOptions.declarationMap;
|
|
852
856
|
}
|
|
857
|
+
emitJs ??= !!(compilerOptions.checkJs || compilerOptions.allowJs);
|
|
853
858
|
if (tsgo && !warnedTsgo) {
|
|
854
859
|
console.warn("The `tsgo` option is experimental and may change in the future.");
|
|
855
860
|
warnedTsgo = true;
|
|
@@ -868,7 +873,8 @@ function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, co
|
|
|
868
873
|
parallel,
|
|
869
874
|
eager,
|
|
870
875
|
tsgo,
|
|
871
|
-
newContext
|
|
876
|
+
newContext,
|
|
877
|
+
emitJs
|
|
872
878
|
};
|
|
873
879
|
}
|
|
874
880
|
|
|
@@ -911,7 +917,7 @@ function createDtsResolvePlugin({ tsconfig, resolve }) {
|
|
|
911
917
|
}
|
|
912
918
|
if (RE_TS.test(resolution) && !RE_DTS.test(resolution) || RE_VUE.test(resolution)) {
|
|
913
919
|
await this.load({ id: resolution });
|
|
914
|
-
resolution =
|
|
920
|
+
resolution = filename_to_dts(resolution);
|
|
915
921
|
}
|
|
916
922
|
if (RE_DTS.test(resolution)) return resolution;
|
|
917
923
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-dts",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"description": "A Rolldown plugin to bundle dts files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@babel/generator": "^7.28.0",
|
|
50
50
|
"@babel/parser": "^7.28.0",
|
|
51
|
-
"@babel/types": "^7.28.
|
|
51
|
+
"@babel/types": "^7.28.2",
|
|
52
52
|
"ast-kit": "^2.1.1",
|
|
53
53
|
"birpc": "^2.5.0",
|
|
54
54
|
"debug": "^4.4.1",
|
|
@@ -56,29 +56,29 @@
|
|
|
56
56
|
"get-tsconfig": "^4.10.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@sxzz/eslint-config": "^7.
|
|
59
|
+
"@sxzz/eslint-config": "^7.1.1",
|
|
60
60
|
"@sxzz/prettier-config": "^2.2.3",
|
|
61
|
-
"@sxzz/test-utils": "^0.5.
|
|
61
|
+
"@sxzz/test-utils": "^0.5.8",
|
|
62
62
|
"@types/babel__generator": "^7.27.0",
|
|
63
63
|
"@types/debug": "^4.1.12",
|
|
64
|
-
"@types/node": "^24.0
|
|
65
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
66
|
-
"@volar/typescript": "^2.4.
|
|
67
|
-
"@vue/language-core": "^3.0.
|
|
68
|
-
"bumpp": "^10.2.
|
|
64
|
+
"@types/node": "^24.1.0",
|
|
65
|
+
"@typescript/native-preview": "7.0.0-dev.20250731.1",
|
|
66
|
+
"@volar/typescript": "^2.4.22",
|
|
67
|
+
"@vue/language-core": "^3.0.4",
|
|
68
|
+
"bumpp": "^10.2.1",
|
|
69
69
|
"diff": "^8.0.2",
|
|
70
|
-
"eslint": "^9.
|
|
70
|
+
"eslint": "^9.32.0",
|
|
71
71
|
"estree-walker": "^3.0.3",
|
|
72
72
|
"prettier": "^3.6.2",
|
|
73
|
-
"rolldown": "^1.0.0-beta.
|
|
73
|
+
"rolldown": "^1.0.0-beta.30",
|
|
74
74
|
"rollup-plugin-dts": "^6.2.1",
|
|
75
75
|
"tinyglobby": "^0.2.14",
|
|
76
|
-
"tsdown": "^0.
|
|
76
|
+
"tsdown": "^0.13.0",
|
|
77
77
|
"tsx": "^4.20.3",
|
|
78
78
|
"typescript": "^5.8.3",
|
|
79
79
|
"vitest": "^3.2.4",
|
|
80
|
-
"vue": "^3.5.
|
|
81
|
-
"vue-tsc": "^3.0.
|
|
80
|
+
"vue": "^3.5.18",
|
|
81
|
+
"vue-tsc": "^3.0.4"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=20.18.0"
|