rolldown-plugin-dts 0.10.0 → 0.11.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 +4 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +19 -37
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ A Rolldown plugin to generate and bundle dts files.
|
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
+
⚠️ Requires `rolldown@1.0.0-beta.8-commit.534fde3` (which is canary) or later.
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
12
|
npm i rolldown-plugin-dts
|
|
11
13
|
```
|
|
@@ -25,7 +27,7 @@ export default {
|
|
|
25
27
|
}
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
You can find
|
|
30
|
+
You can find an example in [here](./rolldown.config.ts).
|
|
29
31
|
|
|
30
32
|
## Options
|
|
31
33
|
|
|
@@ -68,7 +70,7 @@ interface Options {
|
|
|
68
70
|
compilerOptions?: TsConfigJson.CompilerOptions
|
|
69
71
|
|
|
70
72
|
/**
|
|
71
|
-
* When `true`, the plugin will generate `.d.ts` files using
|
|
73
|
+
* When `true`, the plugin will generate `.d.ts` files using Oxc,
|
|
72
74
|
* which is blazingly faster than `typescript` compiler.
|
|
73
75
|
*
|
|
74
76
|
* This option is enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TsConfigJson } from "get-tsconfig";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { TsConfigJson } from "/Users/kevin/Developer/open-source/rolldown-plugin-dts/node_modules/.pnpm/get-tsconfig@4.10.0/node_modules/get-tsconfig/dist/index.mjs";
|
|
2
|
+
import { Plugin } from "/Users/kevin/Developer/open-source/rolldown-plugin-dts/node_modules/.pnpm/rolldown@1.0.0-beta.8-commit.534fde3/node_modules/rolldown/dist/index.mjs";
|
|
3
|
+
import { IsolatedDeclarationsOptions } from "/Users/kevin/Developer/open-source/rolldown-plugin-dts/node_modules/.pnpm/rolldown@1.0.0-beta.8-commit.534fde3/node_modules/rolldown/dist/experimental-index.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/fake-js.d.ts
|
|
6
6
|
declare function createFakeJsPlugin({
|
|
@@ -51,7 +51,7 @@ interface Options {
|
|
|
51
51
|
*/
|
|
52
52
|
compilerOptions?: TsConfigJson.CompilerOptions;
|
|
53
53
|
/**
|
|
54
|
-
* When `true`, the plugin will generate `.d.ts` files using
|
|
54
|
+
* When `true`, the plugin will generate `.d.ts` files using Oxc,
|
|
55
55
|
* which is blazingly faster than `typescript` compiler.
|
|
56
56
|
*
|
|
57
57
|
* This option is enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import _generate from "@babel/generator";
|
|
|
6
6
|
import { parse } from "@babel/parser";
|
|
7
7
|
import * as t from "@babel/types";
|
|
8
8
|
import { isDeclarationType, isTypeOf } from "ast-kit";
|
|
9
|
-
import { isolatedDeclaration } from "
|
|
9
|
+
import { isolatedDeclaration } from "rolldown/experimental";
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
11
|
import { createResolver } from "dts-resolver";
|
|
12
12
|
|
|
@@ -261,24 +261,6 @@ function createFakeJsPlugin({ dtsInput, sourcemap }) {
|
|
|
261
261
|
}
|
|
262
262
|
return {
|
|
263
263
|
name: "rolldown-plugin-dts:fake-js",
|
|
264
|
-
options: dtsInput ? (options) => {
|
|
265
|
-
return {
|
|
266
|
-
...options,
|
|
267
|
-
resolve: {
|
|
268
|
-
extensions: [
|
|
269
|
-
".d.ts",
|
|
270
|
-
".d.mts",
|
|
271
|
-
".d.cts"
|
|
272
|
-
],
|
|
273
|
-
extensionAlias: {
|
|
274
|
-
".js": [".d.ts"],
|
|
275
|
-
".mjs": [".d.mts"],
|
|
276
|
-
".cjs": [".d.cts"]
|
|
277
|
-
},
|
|
278
|
-
...options.resolve
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
} : void 0,
|
|
282
264
|
outputOptions(options) {
|
|
283
265
|
if (options.format === "cjs" || options.format === "commonjs") throw new Error("[rolldown-plugin-dts] Cannot bundle dts files with `cjs` format.");
|
|
284
266
|
return {
|
|
@@ -435,9 +417,11 @@ function createFakeJsPlugin({ dtsInput, sourcemap }) {
|
|
|
435
417
|
generateBundle(options, bundle) {
|
|
436
418
|
for (const chunk of Object.values(bundle)) {
|
|
437
419
|
if (chunk.type !== "asset" || !RE_DTS_MAP.test(chunk.fileName) || typeof chunk.source !== "string") continue;
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
420
|
+
if (sourcemap) {
|
|
421
|
+
const maps = JSON.parse(chunk.source);
|
|
422
|
+
maps.sourcesContent = null;
|
|
423
|
+
chunk.source = JSON.stringify(maps);
|
|
424
|
+
} else delete bundle[chunk.fileName];
|
|
441
425
|
}
|
|
442
426
|
}
|
|
443
427
|
};
|
|
@@ -854,7 +838,6 @@ function createGeneratePlugin({ compilerOptions = {}, isolatedDeclarations, emit
|
|
|
854
838
|
|
|
855
839
|
//#endregion
|
|
856
840
|
//#region src/resolve.ts
|
|
857
|
-
const meta = { dtsFile: true };
|
|
858
841
|
function createDtsResolvePlugin({ tsconfig, resolve }) {
|
|
859
842
|
const resolver = createResolver({
|
|
860
843
|
tsconfig,
|
|
@@ -865,12 +848,7 @@ function createDtsResolvePlugin({ tsconfig, resolve }) {
|
|
|
865
848
|
resolveId: {
|
|
866
849
|
order: "pre",
|
|
867
850
|
async handler(id, importer, options) {
|
|
868
|
-
|
|
869
|
-
id,
|
|
870
|
-
external: true,
|
|
871
|
-
moduleSideEffects: false
|
|
872
|
-
};
|
|
873
|
-
if (!importer || !RE_DTS.test(importer) && !this.getModuleInfo(importer)?.meta.dtsFile) return;
|
|
851
|
+
if (!importer || !RE_DTS.test(importer)) return;
|
|
874
852
|
if (RE_CSS.test(id)) return {
|
|
875
853
|
id,
|
|
876
854
|
external: true,
|
|
@@ -879,24 +857,28 @@ function createDtsResolvePlugin({ tsconfig, resolve }) {
|
|
|
879
857
|
let resolution = resolver(id, importer);
|
|
880
858
|
if (!resolution || !RE_TS.test(resolution)) {
|
|
881
859
|
const result = await this.resolve(id, importer, options);
|
|
882
|
-
if (!result || !RE_TS.test(result.id)) return
|
|
860
|
+
if (!result || !RE_TS.test(result.id)) return {
|
|
861
|
+
id: result?.id || id,
|
|
862
|
+
external: true,
|
|
863
|
+
moduleSideEffects: false
|
|
864
|
+
};
|
|
883
865
|
resolution = result.id;
|
|
884
866
|
}
|
|
885
867
|
if (!RE_NODE_MODULES.test(importer) && RE_NODE_MODULES.test(resolution)) {
|
|
886
868
|
let shouldResolve;
|
|
887
869
|
if (typeof resolve === "boolean") shouldResolve = resolve;
|
|
888
870
|
else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
|
|
889
|
-
if (!shouldResolve) return
|
|
871
|
+
if (!shouldResolve) return {
|
|
872
|
+
id,
|
|
873
|
+
external: true,
|
|
874
|
+
moduleSideEffects: false
|
|
875
|
+
};
|
|
890
876
|
}
|
|
891
877
|
if (RE_TS.test(resolution) && !RE_DTS.test(resolution)) {
|
|
892
|
-
await
|
|
878
|
+
await this.load({ id: resolution });
|
|
893
879
|
resolution = filename_ts_to_dts(resolution);
|
|
894
880
|
}
|
|
895
|
-
if (RE_DTS.test(resolution)) return
|
|
896
|
-
id: resolution,
|
|
897
|
-
meta,
|
|
898
|
-
moduleSideEffects: false
|
|
899
|
-
};
|
|
881
|
+
if (RE_DTS.test(resolution)) return resolution;
|
|
900
882
|
}
|
|
901
883
|
}
|
|
902
884
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-dts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "A Rolldown plugin to bundle dts files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"rolldown": "^1.0.0-beta.
|
|
31
|
+
"rolldown": "^1.0.0-beta.8-commit.534fde3",
|
|
32
32
|
"typescript": "^5.0.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependenciesMeta": {
|
|
@@ -43,8 +43,7 @@
|
|
|
43
43
|
"ast-kit": "^1.4.3",
|
|
44
44
|
"debug": "^4.4.0",
|
|
45
45
|
"dts-resolver": "^1.1.0",
|
|
46
|
-
"get-tsconfig": "^4.10.0"
|
|
47
|
-
"oxc-transform": "^0.67.0"
|
|
46
|
+
"get-tsconfig": "^4.10.0"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
49
|
"@sxzz/eslint-config": "^6.2.0",
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
"eslint": "^9.25.1",
|
|
60
59
|
"estree-walker": "^3.0.3",
|
|
61
60
|
"prettier": "^3.5.3",
|
|
62
|
-
"rolldown": "1.0.0-beta.8-commit.
|
|
61
|
+
"rolldown": "^1.0.0-beta.8-commit.534fde3",
|
|
63
62
|
"rollup-plugin-dts": "^6.2.1",
|
|
64
63
|
"tinyglobby": "^0.2.13",
|
|
65
64
|
"tsdown": "^0.10.2",
|
|
@@ -71,7 +70,7 @@
|
|
|
71
70
|
"node": ">=20.18.0"
|
|
72
71
|
},
|
|
73
72
|
"resolutions": {
|
|
74
|
-
"rolldown": "1.0.0-beta.8-commit.
|
|
73
|
+
"rolldown": "^1.0.0-beta.8-commit.534fde3",
|
|
75
74
|
"rolldown-plugin-dts": "workspace:*"
|
|
76
75
|
},
|
|
77
76
|
"prettier": "@sxzz/prettier-config",
|