rolldown-plugin-dts 0.20.0 → 0.21.0
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 +0 -10
- package/dist/filename-Cqnsj8Gp.mjs +27 -0
- package/dist/filename.mjs +1 -25
- package/dist/{index-DWPGYc3m.d.mts → index-C8o_kIRC.d.mts} +1 -1
- package/dist/index.d.mts +1 -13
- package/dist/index.mjs +14 -17
- package/dist/{tsc-CG1xgNuJ.mjs → tsc-C0UrtIA5.mjs} +4 -3
- package/dist/tsc-context.d.mts +1 -1
- package/dist/tsc-context.mjs +1 -1
- package/dist/tsc-worker.d.mts +1 -2
- package/dist/tsc-worker.mjs +1 -2
- package/dist/tsc.d.mts +1 -2
- package/dist/tsc.mjs +1 -2
- package/package.json +7 -3
- /package/dist/{context-Dt8gPoCq.d.mts → context-CCPZT79j.d.mts} +0 -0
- /package/dist/{context-9CkpILzL.mjs → context-EuY-ImLj.mjs} +0 -0
- /package/dist/{resolver-CyVXxlZv.mjs → resolver-DksQRwY1.mjs} +0 -0
package/README.md
CHANGED
|
@@ -81,16 +81,6 @@ See: [TypeScript compilerOptions documentation](https://www.typescriptlang.org/t
|
|
|
81
81
|
|
|
82
82
|
If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
|
|
83
83
|
|
|
84
|
-
#### `resolve`
|
|
85
|
-
|
|
86
|
-
Controls whether type definitions from `node_modules` are bundled into your final `.d.ts` file or kept as external `import` statements.
|
|
87
|
-
|
|
88
|
-
By default, dependencies are external, resulting in `import { Type } from 'some-package'`. When bundled, this `import` is removed, and the type definitions from `some-package` are copied directly into your file.
|
|
89
|
-
|
|
90
|
-
- `true`: Bundles all dependencies.
|
|
91
|
-
- `false`: (Default) Keeps all dependencies external.
|
|
92
|
-
- `(string | RegExp)[]`: Bundles only dependencies matching the provided strings or regular expressions (e.g. `['pkg-a', /^@scope\//]`).
|
|
93
|
-
|
|
94
84
|
#### `resolver`
|
|
95
85
|
|
|
96
86
|
Specifies a resolver to resolve type definitions, especially for `node_modules`.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/filename.ts
|
|
2
|
+
const RE_JS = /\.([cm]?)jsx?$/;
|
|
3
|
+
const RE_TS = /\.([cm]?)tsx?$/;
|
|
4
|
+
const RE_DTS = /\.d\.([cm]?)ts$/;
|
|
5
|
+
const RE_DTS_MAP = /\.d\.([cm]?)ts\.map$/;
|
|
6
|
+
const RE_NODE_MODULES = /[\\/]node_modules[\\/]/;
|
|
7
|
+
const RE_CSS = /\.css$/;
|
|
8
|
+
const RE_VUE = /\.vue$/;
|
|
9
|
+
const RE_JSON = /\.json$/;
|
|
10
|
+
function filename_js_to_dts(id) {
|
|
11
|
+
return id.replace(RE_JS, ".d.$1ts");
|
|
12
|
+
}
|
|
13
|
+
function filename_to_dts(id) {
|
|
14
|
+
return id.replace(RE_VUE, ".vue.ts").replace(RE_TS, ".d.$1ts").replace(RE_JS, ".d.$1ts").replace(RE_JSON, ".d.ts");
|
|
15
|
+
}
|
|
16
|
+
function filename_dts_to(id, ext) {
|
|
17
|
+
return id.replace(RE_DTS, `.$1${ext}`);
|
|
18
|
+
}
|
|
19
|
+
function resolveTemplateFn(fn, chunk) {
|
|
20
|
+
return typeof fn === "function" ? fn(chunk) : fn;
|
|
21
|
+
}
|
|
22
|
+
function replaceTemplateName(template, name) {
|
|
23
|
+
return template.replaceAll("[name]", name);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { RE_JSON as a, RE_VUE as c, filename_to_dts as d, replaceTemplateName as f, RE_JS as i, filename_dts_to as l, RE_DTS as n, RE_NODE_MODULES as o, resolveTemplateFn as p, RE_DTS_MAP as r, RE_TS as s, RE_CSS as t, filename_js_to_dts as u };
|
package/dist/filename.mjs
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
const RE_JS = /\.([cm]?)jsx?$/;
|
|
3
|
-
const RE_TS = /\.([cm]?)tsx?$/;
|
|
4
|
-
const RE_DTS = /\.d\.([cm]?)ts$/;
|
|
5
|
-
const RE_DTS_MAP = /\.d\.([cm]?)ts\.map$/;
|
|
6
|
-
const RE_NODE_MODULES = /[\\/]node_modules[\\/]/;
|
|
7
|
-
const RE_CSS = /\.css$/;
|
|
8
|
-
const RE_VUE = /\.vue$/;
|
|
9
|
-
const RE_JSON = /\.json$/;
|
|
10
|
-
function filename_js_to_dts(id) {
|
|
11
|
-
return id.replace(RE_JS, ".d.$1ts");
|
|
12
|
-
}
|
|
13
|
-
function filename_to_dts(id) {
|
|
14
|
-
return id.replace(RE_VUE, ".vue.ts").replace(RE_TS, ".d.$1ts").replace(RE_JS, ".d.$1ts").replace(RE_JSON, ".d.ts");
|
|
15
|
-
}
|
|
16
|
-
function filename_dts_to(id, ext) {
|
|
17
|
-
return id.replace(RE_DTS, `.$1${ext}`);
|
|
18
|
-
}
|
|
19
|
-
function resolveTemplateFn(fn, chunk) {
|
|
20
|
-
return typeof fn === "function" ? fn(chunk) : fn;
|
|
21
|
-
}
|
|
22
|
-
function replaceTemplateName(template, name) {
|
|
23
|
-
return template.replaceAll("[name]", name);
|
|
24
|
-
}
|
|
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-Cqnsj8Gp.mjs";
|
|
25
2
|
|
|
26
|
-
//#endregion
|
|
27
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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_TS, RE_VUE } from "./filename.mjs";
|
|
2
1
|
import { IsolatedDeclarationsOptions } from "rolldown/experimental";
|
|
3
2
|
import { TsConfigJson } from "get-tsconfig";
|
|
4
3
|
import { Plugin } from "rolldown";
|
|
@@ -47,16 +46,6 @@ interface GeneralOptions {
|
|
|
47
46
|
*/
|
|
48
47
|
sourcemap?: boolean;
|
|
49
48
|
/**
|
|
50
|
-
* Controls whether type definitions from `node_modules` are bundled into your final `.d.ts` file or kept as external `import` statements.
|
|
51
|
-
*
|
|
52
|
-
* By default, dependencies are external, resulting in `import { Type } from 'some-package'`. When bundled, this `import` is removed, and the type definitions from `some-package` are copied directly into your file.
|
|
53
|
-
|
|
54
|
-
* - `true`: Bundles all dependencies.
|
|
55
|
-
* - `false`: (Default) Keeps all dependencies external.
|
|
56
|
-
* - `(string | RegExp)[]`: Bundles only dependencies matching the provided strings or regular expressions (e.g. `['pkg-a', /^@scope\//]`).
|
|
57
|
-
*/
|
|
58
|
-
resolve?: boolean | (string | RegExp)[];
|
|
59
|
-
/**
|
|
60
49
|
* Specifies a resolver to resolve type definitions, especially for `node_modules`.
|
|
61
50
|
*
|
|
62
51
|
* - `'oxc'`: Uses Oxc's module resolution, which is faster and more efficient.
|
|
@@ -194,7 +183,6 @@ declare function resolveOptions({
|
|
|
194
183
|
tsconfigRaw: overriddenTsconfigRaw,
|
|
195
184
|
compilerOptions,
|
|
196
185
|
sourcemap,
|
|
197
|
-
resolve,
|
|
198
186
|
resolver,
|
|
199
187
|
cjsDefault,
|
|
200
188
|
sideEffects,
|
|
@@ -239,4 +227,4 @@ declare function createGeneratePlugin({
|
|
|
239
227
|
//#region src/index.d.ts
|
|
240
228
|
declare function dts(options?: Options): Plugin[];
|
|
241
229
|
//#endregion
|
|
242
|
-
export { type Options,
|
|
230
|
+
export { type Options, createFakeJsPlugin, createGeneratePlugin, dts, resolveOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-
|
|
2
|
+
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-Cqnsj8Gp.mjs";
|
|
3
|
+
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-EuY-ImLj.mjs";
|
|
4
4
|
import { createDebug } from "obug";
|
|
5
5
|
const {
|
|
6
6
|
generate
|
|
@@ -30,6 +30,7 @@ import { ResolverFactory, isolatedDeclarationSync } from "rolldown/experimental"
|
|
|
30
30
|
const process = globalThis.process;
|
|
31
31
|
import { getTsconfig, parseTsconfig } from "get-tsconfig";
|
|
32
32
|
import { createResolver } from "dts-resolver";
|
|
33
|
+
import { importerId, include } from "rolldown/filter";
|
|
33
34
|
|
|
34
35
|
//#region src/dts-input.ts
|
|
35
36
|
function createDtsInputPlugin({ sideEffects }) {
|
|
@@ -851,7 +852,7 @@ function collectJsonExports(code) {
|
|
|
851
852
|
//#endregion
|
|
852
853
|
//#region src/options.ts
|
|
853
854
|
let warnedTsgo = false;
|
|
854
|
-
function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap,
|
|
855
|
+
function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap, resolver = "oxc", cjsDefault = false, sideEffects = false, build = false, incremental = false, vue = false, tsMacro = false, parallel = false, eager = false, newContext = false, emitJs, oxc, tsgo = false }) {
|
|
855
856
|
let resolvedTsconfig;
|
|
856
857
|
if (tsconfig === true || tsconfig == null) {
|
|
857
858
|
const { config, path: path$1 } = getTsconfig(cwd) || {};
|
|
@@ -898,7 +899,6 @@ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = f
|
|
|
898
899
|
tsconfig,
|
|
899
900
|
tsconfigRaw,
|
|
900
901
|
sourcemap,
|
|
901
|
-
resolve,
|
|
902
902
|
resolver,
|
|
903
903
|
cjsDefault,
|
|
904
904
|
sideEffects,
|
|
@@ -921,10 +921,10 @@ const debug$1 = createDebug("rolldown-plugin-dts:resolver");
|
|
|
921
921
|
function isSourceFile(id) {
|
|
922
922
|
return RE_TS.test(id) || RE_VUE.test(id) || RE_JSON.test(id);
|
|
923
923
|
}
|
|
924
|
-
function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw,
|
|
924
|
+
function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolver, sideEffects }) {
|
|
925
925
|
const baseDtsResolver = createResolver({
|
|
926
926
|
tsconfig,
|
|
927
|
-
resolveNodeModules:
|
|
927
|
+
resolveNodeModules: true,
|
|
928
928
|
ResolverFactory
|
|
929
929
|
});
|
|
930
930
|
const moduleSideEffects = sideEffects ? true : null;
|
|
@@ -932,8 +932,9 @@ function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolve, resolver,
|
|
|
932
932
|
name: "rolldown-plugin-dts:resolver",
|
|
933
933
|
resolveId: {
|
|
934
934
|
order: "pre",
|
|
935
|
+
filter: [include(importerId(RE_DTS))],
|
|
935
936
|
async handler(id, importer, options) {
|
|
936
|
-
if (!importer
|
|
937
|
+
if (!importer) return;
|
|
937
938
|
const external = {
|
|
938
939
|
id,
|
|
939
940
|
external: true,
|
|
@@ -945,16 +946,16 @@ function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolve, resolver,
|
|
|
945
946
|
}
|
|
946
947
|
const rolldownResolution = await this.resolve(id, importer, options);
|
|
947
948
|
debug$1("Rolldown resolution for dts import %O from %O: %O", id, importer, rolldownResolution);
|
|
949
|
+
if (rolldownResolution?.external) {
|
|
950
|
+
debug$1("Rolldown marked dts import as external:", id);
|
|
951
|
+
return external;
|
|
952
|
+
}
|
|
948
953
|
const dtsResolution = await resolveDtsPath(id, importer, rolldownResolution);
|
|
949
954
|
debug$1("Dts resolution for dts import %O from %O: %O", id, importer, dtsResolution);
|
|
950
955
|
if (!dtsResolution) {
|
|
951
956
|
debug$1("Unresolvable dts import:", id, "from", importer);
|
|
952
957
|
return isFilePath(id) ? null : external;
|
|
953
958
|
}
|
|
954
|
-
if (RE_NODE_MODULES.test(dtsResolution) && !shouldBundleNodeModule(id) && (!RE_NODE_MODULES.test(importer) || rolldownResolution?.external)) {
|
|
955
|
-
debug$1("Externalizing node_modules dts import:", id);
|
|
956
|
-
return external;
|
|
957
|
-
}
|
|
958
959
|
if (RE_DTS.test(dtsResolution)) {
|
|
959
960
|
debug$1("Resolving dts import to declaration file:", id);
|
|
960
961
|
return {
|
|
@@ -973,14 +974,10 @@ function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolve, resolver,
|
|
|
973
974
|
}
|
|
974
975
|
}
|
|
975
976
|
};
|
|
976
|
-
function shouldBundleNodeModule(id) {
|
|
977
|
-
if (typeof resolve === "boolean") return resolve;
|
|
978
|
-
return resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
|
|
979
|
-
}
|
|
980
977
|
async function resolveDtsPath(id, importer, rolldownResolution) {
|
|
981
978
|
let dtsPath;
|
|
982
979
|
if (resolver === "tsc") {
|
|
983
|
-
const { tscResolve } = await import("./resolver-
|
|
980
|
+
const { tscResolve } = await import("./resolver-DksQRwY1.mjs");
|
|
984
981
|
dtsPath = tscResolve(id, importer, cwd, tsconfig, tsconfigRaw);
|
|
985
982
|
} else dtsPath = baseDtsResolver(id, importer);
|
|
986
983
|
debug$1("Using %s for dts import: %O -> %O", resolver, id, dtsPath);
|
|
@@ -1011,4 +1008,4 @@ function dts(options = {}) {
|
|
|
1011
1008
|
}
|
|
1012
1009
|
|
|
1013
1010
|
//#endregion
|
|
1014
|
-
export {
|
|
1011
|
+
export { createFakeJsPlugin, createGeneratePlugin, dts, resolveOptions };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
|
|
2
|
-
import { n as
|
|
2
|
+
import { n as RE_DTS, r as RE_DTS_MAP } from "./filename-Cqnsj8Gp.mjs";
|
|
3
|
+
import { n as globalContext } from "./context-EuY-ImLj.mjs";
|
|
3
4
|
const {
|
|
4
5
|
createRequire
|
|
5
6
|
} = globalThis.process.getBuiltinModule("node:module");
|
|
@@ -108,7 +109,7 @@ function tscEmitBuild(tscOptions) {
|
|
|
108
109
|
let code;
|
|
109
110
|
let map;
|
|
110
111
|
for (const outputFile of outputFiles) {
|
|
111
|
-
if (
|
|
112
|
+
if (RE_DTS.test(outputFile)) {
|
|
112
113
|
if (!fsSystem.fileExists(outputFile)) {
|
|
113
114
|
console.warn(`[rolldown-plugin-dts] Unable to read file ${outputFile}`);
|
|
114
115
|
continue;
|
|
@@ -116,7 +117,7 @@ function tscEmitBuild(tscOptions) {
|
|
|
116
117
|
code = fsSystem.readFile(outputFile);
|
|
117
118
|
continue;
|
|
118
119
|
}
|
|
119
|
-
if (
|
|
120
|
+
if (RE_DTS_MAP.test(outputFile)) {
|
|
120
121
|
if (!fsSystem.fileExists(outputFile)) continue;
|
|
121
122
|
const text = fsSystem.readFile(outputFile);
|
|
122
123
|
if (!text) {
|
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-CCPZT79j.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-EuY-ImLj.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,3 +1,2 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-DWPGYc3m.mjs";
|
|
1
|
+
import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-C8o_kIRC.mjs";
|
|
3
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.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"description": "A Rolldown plugin to generate and bundle dts files.",
|
|
6
6
|
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@sxzz/test-utils": "^0.5.15",
|
|
80
80
|
"@types/babel__generator": "^7.27.0",
|
|
81
81
|
"@types/node": "^25.0.3",
|
|
82
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
82
|
+
"@typescript/native-preview": "7.0.0-dev.20251228.1",
|
|
83
83
|
"@volar/typescript": "^2.4.27",
|
|
84
84
|
"@vue/language-core": "^3.2.1",
|
|
85
85
|
"arktype": "^2.1.29",
|
|
@@ -88,15 +88,19 @@
|
|
|
88
88
|
"eslint": "^9.39.2",
|
|
89
89
|
"prettier": "^3.7.4",
|
|
90
90
|
"rolldown": "^1.0.0-beta.57",
|
|
91
|
+
"rolldown-plugin-dts-snapshot": "^0.3.2",
|
|
91
92
|
"rolldown-plugin-require-cjs": "^0.3.3",
|
|
92
93
|
"rollup-plugin-dts": "^6.3.0",
|
|
93
94
|
"tinyglobby": "^0.2.15",
|
|
94
|
-
"tsdown": "^0.18.
|
|
95
|
+
"tsdown": "^0.18.3",
|
|
95
96
|
"typescript": "^5.9.3",
|
|
96
97
|
"vitest": "^4.0.16",
|
|
97
98
|
"vue": "^3.5.26",
|
|
98
99
|
"vue-tsc": "^3.2.1"
|
|
99
100
|
},
|
|
101
|
+
"resolutions": {
|
|
102
|
+
"rolldown": "^1.0.0-beta.57"
|
|
103
|
+
},
|
|
100
104
|
"prettier": "@sxzz/prettier-config",
|
|
101
105
|
"scripts": {
|
|
102
106
|
"lint": "eslint --cache .",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|