rolldown-plugin-dts 0.15.0 → 0.15.2
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 -1
- package/dist/{index-D_X_vGiL.d.ts → index-BPD4iQBs.d.ts} +1 -0
- package/dist/index.d.ts +54 -39
- package/dist/index.js +11 -8
- package/dist/{tsc-BjWJCGE1.js → tsc-BSxLVaDe.js} +2 -2
- package/dist/tsc-worker.d.ts +1 -1
- package/dist/tsc-worker.js +1 -1
- package/dist/tsc.d.ts +1 -1
- package/dist/tsc.js +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -91,11 +91,19 @@ Resolve external types used in `.d.ts` files from `node_modules`.
|
|
|
91
91
|
> [!NOTE]
|
|
92
92
|
> These options are only applicable when `oxc` and `tsgo` are not enabled.
|
|
93
93
|
|
|
94
|
+
#### `build`
|
|
95
|
+
|
|
96
|
+
Build mode for the TypeScript compiler:
|
|
97
|
+
|
|
98
|
+
- 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.
|
|
99
|
+
- 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.
|
|
100
|
+
|
|
101
|
+
**Default:** `false`
|
|
102
|
+
|
|
94
103
|
#### `incremental`
|
|
95
104
|
|
|
96
105
|
Controls how project references and incremental builds are handled:
|
|
97
106
|
|
|
98
|
-
- If your `tsconfig.json` uses [`references`](https://www.typescriptlang.org/tsconfig/#references), 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.
|
|
99
107
|
- If `incremental` is `true`, all built files (including [`.tsbuildinfo`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)) will be written to disk, similar to running `tsc -b` in your project.
|
|
100
108
|
- If `incremental` is `false`, built files are kept in memory, minimizing disk usage.
|
|
101
109
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { TsConfigJson } from "get-tsconfig";
|
|
|
4
4
|
import { Plugin } from "rolldown";
|
|
5
5
|
|
|
6
6
|
//#region src/options.d.ts
|
|
7
|
-
interface
|
|
7
|
+
interface GeneralOptions {
|
|
8
8
|
/**
|
|
9
9
|
* The directory in which the plugin will search for the `tsconfig.json` file.
|
|
10
10
|
*/
|
|
@@ -37,6 +37,31 @@ interface Options {
|
|
|
37
37
|
*/
|
|
38
38
|
tsconfigRaw?: Omit<TsConfigJson, "compilerOptions">;
|
|
39
39
|
/**
|
|
40
|
+
* Override the `compilerOptions` specified in `tsconfig.json`.
|
|
41
|
+
*
|
|
42
|
+
* @see https://www.typescriptlang.org/tsconfig/#compilerOptions
|
|
43
|
+
*/
|
|
44
|
+
compilerOptions?: TsConfigJson.CompilerOptions;
|
|
45
|
+
/**
|
|
46
|
+
* If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
|
|
47
|
+
*/
|
|
48
|
+
sourcemap?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve external types used in `.d.ts` files from `node_modules`.
|
|
51
|
+
*/
|
|
52
|
+
resolve?: boolean | (string | RegExp)[];
|
|
53
|
+
}
|
|
54
|
+
interface TscOptions {
|
|
55
|
+
/**
|
|
56
|
+
* Build mode for the TypeScript compiler:
|
|
57
|
+
*
|
|
58
|
+
* - 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.
|
|
59
|
+
* - 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.
|
|
60
|
+
*
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
build?: boolean;
|
|
64
|
+
/**
|
|
40
65
|
* If your tsconfig.json has
|
|
41
66
|
* [`references`](https://www.typescriptlang.org/tsconfig/#references) option,
|
|
42
67
|
* `rolldown-plugin-dts` will use [`tsc
|
|
@@ -67,27 +92,6 @@ interface Options {
|
|
|
67
92
|
*/
|
|
68
93
|
incremental?: boolean;
|
|
69
94
|
/**
|
|
70
|
-
* Override the `compilerOptions` specified in `tsconfig.json`.
|
|
71
|
-
*
|
|
72
|
-
* @see https://www.typescriptlang.org/tsconfig/#compilerOptions
|
|
73
|
-
*/
|
|
74
|
-
compilerOptions?: TsConfigJson.CompilerOptions;
|
|
75
|
-
/**
|
|
76
|
-
* If `true`, the plugin will generate `.d.ts` files using Oxc,
|
|
77
|
-
* which is significantly faster than the TypeScript compiler.
|
|
78
|
-
*
|
|
79
|
-
* This option is automatically enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
|
|
80
|
-
*/
|
|
81
|
-
oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
|
|
82
|
-
/**
|
|
83
|
-
* If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
|
|
84
|
-
*/
|
|
85
|
-
sourcemap?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Resolve external types used in `.d.ts` files from `node_modules`.
|
|
88
|
-
*/
|
|
89
|
-
resolve?: boolean | (string | RegExp)[];
|
|
90
|
-
/**
|
|
91
95
|
* If `true`, the plugin will generate `.d.ts` files using `vue-tsc`.
|
|
92
96
|
*/
|
|
93
97
|
vue?: boolean;
|
|
@@ -103,15 +107,6 @@ interface Options {
|
|
|
103
107
|
*/
|
|
104
108
|
eager?: boolean;
|
|
105
109
|
/**
|
|
106
|
-
* **[Experimental]** Enables DTS generation using `tsgo`.
|
|
107
|
-
*
|
|
108
|
-
* To use this option, make sure `@typescript/native-preview` is installed as a dependency.
|
|
109
|
-
*
|
|
110
|
-
* **Note:** This option is not yet recommended for production environments.
|
|
111
|
-
* `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
|
|
112
|
-
*/
|
|
113
|
-
tsgo?: boolean;
|
|
114
|
-
/**
|
|
115
110
|
* If `true`, the plugin will create a new isolated context for each build,
|
|
116
111
|
* ensuring that previously generated `.d.ts` code and caches are not reused.
|
|
117
112
|
*
|
|
@@ -132,6 +127,24 @@ interface Options {
|
|
|
132
127
|
*/
|
|
133
128
|
emitJs?: boolean;
|
|
134
129
|
}
|
|
130
|
+
interface Options extends GeneralOptions, TscOptions {
|
|
131
|
+
/**
|
|
132
|
+
* If `true`, the plugin will generate `.d.ts` files using Oxc,
|
|
133
|
+
* which is significantly faster than the TypeScript compiler.
|
|
134
|
+
*
|
|
135
|
+
* This option is automatically enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
|
|
136
|
+
*/
|
|
137
|
+
oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
|
|
138
|
+
/**
|
|
139
|
+
* **[Experimental]** Enables DTS generation using `tsgo`.
|
|
140
|
+
*
|
|
141
|
+
* To use this option, make sure `@typescript/native-preview` is installed as a dependency.
|
|
142
|
+
*
|
|
143
|
+
* **Note:** This option is not yet recommended for production environments.
|
|
144
|
+
* `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
|
|
145
|
+
*/
|
|
146
|
+
tsgo?: boolean;
|
|
147
|
+
}
|
|
135
148
|
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
136
149
|
type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
|
|
137
150
|
tsconfig: string | undefined;
|
|
@@ -140,21 +153,22 @@ type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
|
|
|
140
153
|
}>;
|
|
141
154
|
declare function resolveOptions({
|
|
142
155
|
cwd,
|
|
156
|
+
dtsInput,
|
|
157
|
+
emitDtsOnly,
|
|
143
158
|
tsconfig,
|
|
144
|
-
incremental,
|
|
145
|
-
compilerOptions,
|
|
146
159
|
tsconfigRaw: overriddenTsconfigRaw,
|
|
147
|
-
|
|
160
|
+
compilerOptions,
|
|
148
161
|
sourcemap,
|
|
149
|
-
dtsInput,
|
|
150
|
-
emitDtsOnly,
|
|
151
162
|
resolve,
|
|
163
|
+
build,
|
|
164
|
+
incremental,
|
|
152
165
|
vue,
|
|
153
166
|
parallel,
|
|
154
167
|
eager,
|
|
155
|
-
tsgo,
|
|
156
168
|
newContext,
|
|
157
|
-
emitJs
|
|
169
|
+
emitJs,
|
|
170
|
+
oxc,
|
|
171
|
+
tsgo
|
|
158
172
|
}: Options): OptionsResolved;
|
|
159
173
|
//#endregion
|
|
160
174
|
//#region src/fake-js.d.ts
|
|
@@ -167,6 +181,7 @@ declare function createFakeJsPlugin({
|
|
|
167
181
|
declare function createGeneratePlugin({
|
|
168
182
|
tsconfig,
|
|
169
183
|
tsconfigRaw,
|
|
184
|
+
build,
|
|
170
185
|
incremental,
|
|
171
186
|
cwd,
|
|
172
187
|
oxc,
|
|
@@ -177,7 +192,7 @@ declare function createGeneratePlugin({
|
|
|
177
192
|
tsgo,
|
|
178
193
|
newContext,
|
|
179
194
|
emitJs
|
|
180
|
-
}: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs">): Plugin;
|
|
195
|
+
}: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "build" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs">): Plugin;
|
|
181
196
|
//#endregion
|
|
182
197
|
//#region src/index.d.ts
|
|
183
198
|
declare function dts(options?: Options): Plugin[];
|
package/dist/index.js
CHANGED
|
@@ -627,6 +627,7 @@ function inheritNodeComments(oldNode, newNode) {
|
|
|
627
627
|
const leadingComments = oldNode.leadingComments?.filter((comment) => comment.value.startsWith("#"));
|
|
628
628
|
if (leadingComments) newNode.leadingComments.unshift(...leadingComments);
|
|
629
629
|
newNode.leadingComments = collectReferenceDirectives(newNode.leadingComments, true);
|
|
630
|
+
newNode.trailingComments = newNode.trailingComments?.filter((comment) => !comment.value.startsWith("# sourceMappingURL"));
|
|
630
631
|
return newNode;
|
|
631
632
|
}
|
|
632
633
|
|
|
@@ -639,7 +640,7 @@ const spawnAsync = (...args) => new Promise((resolve, reject) => {
|
|
|
639
640
|
child.on("close", () => resolve());
|
|
640
641
|
child.on("error", (error) => reject(error));
|
|
641
642
|
});
|
|
642
|
-
function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, oxc, emitDtsOnly, vue, parallel, eager, tsgo, newContext, emitJs }) {
|
|
643
|
+
function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd, oxc, emitDtsOnly, vue, parallel, eager, tsgo, newContext, emitJs }) {
|
|
643
644
|
const dtsMap = /* @__PURE__ */ new Map();
|
|
644
645
|
/**
|
|
645
646
|
* A map of input id to output file name
|
|
@@ -765,6 +766,7 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, oxc, em
|
|
|
765
766
|
const options = {
|
|
766
767
|
tsconfig,
|
|
767
768
|
tsconfigRaw,
|
|
769
|
+
build,
|
|
768
770
|
incremental,
|
|
769
771
|
cwd,
|
|
770
772
|
entries,
|
|
@@ -827,7 +829,7 @@ async function runTsgo(root, tsconfig) {
|
|
|
827
829
|
//#endregion
|
|
828
830
|
//#region src/options.ts
|
|
829
831
|
let warnedTsgo = false;
|
|
830
|
-
function resolveOptions({ cwd = process.cwd(),
|
|
832
|
+
function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap, resolve = false, build = false, incremental = false, vue = false, parallel = false, eager = false, newContext = false, emitJs, oxc, tsgo = false }) {
|
|
831
833
|
let resolvedTsconfig;
|
|
832
834
|
if (tsconfig === true || tsconfig == null) {
|
|
833
835
|
const { config, path: path$1 } = getTsconfig(cwd) || {};
|
|
@@ -867,20 +869,21 @@ function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, co
|
|
|
867
869
|
}
|
|
868
870
|
return {
|
|
869
871
|
cwd,
|
|
872
|
+
dtsInput,
|
|
873
|
+
emitDtsOnly,
|
|
870
874
|
tsconfig,
|
|
871
875
|
tsconfigRaw,
|
|
872
|
-
incremental,
|
|
873
|
-
oxc,
|
|
874
876
|
sourcemap,
|
|
875
|
-
dtsInput,
|
|
876
|
-
emitDtsOnly,
|
|
877
877
|
resolve,
|
|
878
|
+
build,
|
|
879
|
+
incremental,
|
|
878
880
|
vue,
|
|
879
881
|
parallel,
|
|
880
882
|
eager,
|
|
881
|
-
tsgo,
|
|
882
883
|
newContext,
|
|
883
|
-
emitJs
|
|
884
|
+
emitJs,
|
|
885
|
+
oxc,
|
|
886
|
+
tsgo
|
|
884
887
|
};
|
|
885
888
|
}
|
|
886
889
|
|
|
@@ -177,11 +177,11 @@ function parseTsconfig(tsconfigPath, fsSystem) {
|
|
|
177
177
|
if (diagnostics.length) throw new Error(`[rolldown-plugin-dts] Unable to read ${tsconfigPath}: ${ts.formatDiagnostics(diagnostics, formatHost)}`);
|
|
178
178
|
return parsedConfig;
|
|
179
179
|
}
|
|
180
|
-
function createTsProgram({ entries, id, tsconfig, tsconfigRaw, incremental, vue, cwd, context = globalContext }) {
|
|
180
|
+
function createTsProgram({ entries, id, tsconfig, tsconfigRaw, build, incremental, vue, cwd, context = globalContext }) {
|
|
181
181
|
const fsSystem = createFsSystem(context.files);
|
|
182
182
|
const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
|
|
183
183
|
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir);
|
|
184
|
-
if (tsconfig &&
|
|
184
|
+
if (tsconfig && build) {
|
|
185
185
|
const projectPaths = buildSolution(tsconfig, incremental, context);
|
|
186
186
|
debug(`collected projects: ${JSON.stringify(projectPaths)}`);
|
|
187
187
|
const project = findProjectContainingFile(projectPaths, id, fsSystem);
|
package/dist/tsc-worker.d.ts
CHANGED
package/dist/tsc-worker.js
CHANGED
package/dist/tsc.d.ts
CHANGED
package/dist/tsc.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-dts",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "A Rolldown plugin to bundle dts files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,23 +64,23 @@
|
|
|
64
64
|
"@sxzz/test-utils": "^0.5.9",
|
|
65
65
|
"@types/babel__generator": "^7.27.0",
|
|
66
66
|
"@types/debug": "^4.1.12",
|
|
67
|
-
"@types/node": "^24.
|
|
68
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
67
|
+
"@types/node": "^24.2.0",
|
|
68
|
+
"@typescript/native-preview": "7.0.0-dev.20250804.1",
|
|
69
69
|
"@volar/typescript": "^2.4.22",
|
|
70
|
-
"@vue/language-core": "^3.0.
|
|
71
|
-
"bumpp": "^10.2.
|
|
70
|
+
"@vue/language-core": "^3.0.5",
|
|
71
|
+
"bumpp": "^10.2.2",
|
|
72
72
|
"diff": "^8.0.2",
|
|
73
73
|
"eslint": "^9.32.0",
|
|
74
74
|
"estree-walker": "^3.0.3",
|
|
75
75
|
"prettier": "^3.6.2",
|
|
76
|
-
"rolldown": "^1.0.0-beta.
|
|
76
|
+
"rolldown": "^1.0.0-beta.31",
|
|
77
77
|
"rollup-plugin-dts": "^6.2.1",
|
|
78
78
|
"tinyglobby": "^0.2.14",
|
|
79
|
-
"tsdown": "^0.13.
|
|
80
|
-
"typescript": "^5.
|
|
79
|
+
"tsdown": "^0.13.2",
|
|
80
|
+
"typescript": "^5.9.2",
|
|
81
81
|
"vitest": "^3.2.4",
|
|
82
82
|
"vue": "^3.5.18",
|
|
83
|
-
"vue-tsc": "^3.0.
|
|
83
|
+
"vue-tsc": "^3.0.5"
|
|
84
84
|
},
|
|
85
85
|
"engines": {
|
|
86
86
|
"node": ">=20.18.0"
|