rolldown-plugin-dts 0.10.1 → 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 +17 -12
- 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
|
|
|
@@ -417,9 +417,11 @@ function createFakeJsPlugin({ dtsInput, sourcemap }) {
|
|
|
417
417
|
generateBundle(options, bundle) {
|
|
418
418
|
for (const chunk of Object.values(bundle)) {
|
|
419
419
|
if (chunk.type !== "asset" || !RE_DTS_MAP.test(chunk.fileName) || typeof chunk.source !== "string") continue;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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];
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
427
|
};
|
|
@@ -846,11 +848,6 @@ function createDtsResolvePlugin({ tsconfig, resolve }) {
|
|
|
846
848
|
resolveId: {
|
|
847
849
|
order: "pre",
|
|
848
850
|
async handler(id, importer, options) {
|
|
849
|
-
const external = {
|
|
850
|
-
id,
|
|
851
|
-
external: true,
|
|
852
|
-
moduleSideEffects: false
|
|
853
|
-
};
|
|
854
851
|
if (!importer || !RE_DTS.test(importer)) return;
|
|
855
852
|
if (RE_CSS.test(id)) return {
|
|
856
853
|
id,
|
|
@@ -860,17 +857,25 @@ function createDtsResolvePlugin({ tsconfig, resolve }) {
|
|
|
860
857
|
let resolution = resolver(id, importer);
|
|
861
858
|
if (!resolution || !RE_TS.test(resolution)) {
|
|
862
859
|
const result = await this.resolve(id, importer, options);
|
|
863
|
-
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
|
+
};
|
|
864
865
|
resolution = result.id;
|
|
865
866
|
}
|
|
866
867
|
if (!RE_NODE_MODULES.test(importer) && RE_NODE_MODULES.test(resolution)) {
|
|
867
868
|
let shouldResolve;
|
|
868
869
|
if (typeof resolve === "boolean") shouldResolve = resolve;
|
|
869
870
|
else shouldResolve = resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
|
|
870
|
-
if (!shouldResolve) return
|
|
871
|
+
if (!shouldResolve) return {
|
|
872
|
+
id,
|
|
873
|
+
external: true,
|
|
874
|
+
moduleSideEffects: false
|
|
875
|
+
};
|
|
871
876
|
}
|
|
872
877
|
if (RE_TS.test(resolution) && !RE_DTS.test(resolution)) {
|
|
873
|
-
await
|
|
878
|
+
await this.load({ id: resolution });
|
|
874
879
|
resolution = filename_ts_to_dts(resolution);
|
|
875
880
|
}
|
|
876
881
|
if (RE_DTS.test(resolution)) return resolution;
|
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",
|