rolldown-plugin-dts 0.7.0 → 0.7.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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -15
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ interface Options {
|
|
|
56
56
|
* When `true`, the plugin will generate `.d.ts` files using `oxc-transform`,
|
|
57
57
|
* which is blazingly faster than `typescript` compiler.
|
|
58
58
|
*
|
|
59
|
-
* This option is enabled when `
|
|
59
|
+
* This option is enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
|
|
60
60
|
*/
|
|
61
61
|
isolatedDeclaration?: boolean | Omit<IsolatedDeclarationsOptions, 'sourcemap'>
|
|
62
62
|
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ interface Options {
|
|
|
35
35
|
* When `true`, the plugin will generate `.d.ts` files using `oxc-transform`,
|
|
36
36
|
* which is blazingly faster than `typescript` compiler.
|
|
37
37
|
*
|
|
38
|
-
* This option is enabled when `
|
|
38
|
+
* This option is enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
|
|
39
39
|
*/
|
|
40
40
|
isolatedDeclaration?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
|
|
41
41
|
/** Resolve external types used in dts files from `node_modules` */
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MagicStringAST } from "magic-string-ast";
|
|
2
2
|
import { parseSync } from "oxc-parser";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import process from "node:process";
|
|
5
4
|
import { createResolver } from "dts-resolver";
|
|
6
5
|
import { getTsconfig } from "get-tsconfig";
|
|
7
6
|
import { isolatedDeclaration } from "oxc-transform";
|
|
@@ -172,7 +171,7 @@ function getIdentifierRange(node, offset = 0) {
|
|
|
172
171
|
//#endregion
|
|
173
172
|
//#region src/utils/filename.ts
|
|
174
173
|
const RE_JS = /\.([cm]?)js$/;
|
|
175
|
-
const RE_TS = /\.([cm]?)
|
|
174
|
+
const RE_TS = /\.([cm]?)tsx?$/;
|
|
176
175
|
const RE_DTS = /\.d\.([cm]?)ts$/;
|
|
177
176
|
const RE_NODE_MODULES = /node_modules/;
|
|
178
177
|
function filename_js_to_dts(id) {
|
|
@@ -374,17 +373,18 @@ function collectDependencies(s, node, getIdentifierIndex) {
|
|
|
374
373
|
if (node$1.computed && isReferenceId(node$1.key)) addDependency(node$1.key);
|
|
375
374
|
if ("value" in node$1 && isReferenceId(node$1.value)) addDependency(node$1.value);
|
|
376
375
|
} else if (node$1.type === "TSTypeReference") addDependency(node$1.typeName);
|
|
377
|
-
else if (node$1.type === "TSTypeQuery")
|
|
378
|
-
|
|
376
|
+
else if (node$1.type === "TSTypeQuery") {
|
|
377
|
+
if (node$1.exprName.type !== "TSImportType") addDependency(node$1.exprName);
|
|
378
|
+
} else if (node$1.type === "TSImportType") {
|
|
379
379
|
if (node$1.argument.type !== "TSLiteralType" || node$1.argument.literal.type !== "Literal" || typeof node$1.argument.literal.value !== "string") return;
|
|
380
380
|
const source = node$1.argument.literal.value;
|
|
381
|
-
const imported = node$1.qualifier &&
|
|
382
|
-
const local = importNamespace(s, source, imported, getIdentifierIndex);
|
|
381
|
+
const imported = node$1.qualifier && resolveTSTypeName(node$1.qualifier);
|
|
382
|
+
const local = importNamespace(s, source, imported && s.sliceNode(imported), getIdentifierIndex);
|
|
383
383
|
addDependency({
|
|
384
384
|
type: "Identifier",
|
|
385
385
|
name: local,
|
|
386
|
-
start: node$1.start
|
|
387
|
-
end:
|
|
386
|
+
start: node$1.start,
|
|
387
|
+
end: imported ? imported.end : node$1.end
|
|
388
388
|
});
|
|
389
389
|
}
|
|
390
390
|
} });
|
|
@@ -394,6 +394,10 @@ function collectDependencies(s, node, getIdentifierIndex) {
|
|
|
394
394
|
deps.add(node$1);
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
+
function resolveTSTypeName(node) {
|
|
398
|
+
if (node.type === "Identifier") return node;
|
|
399
|
+
return resolveTSTypeName(node.left);
|
|
400
|
+
}
|
|
397
401
|
function isReferenceId(node) {
|
|
398
402
|
return !!node && (node.type === "Identifier" || node.type === "MemberExpression");
|
|
399
403
|
}
|
|
@@ -574,7 +578,7 @@ function createGeneratePlugin({ compilerOptions, isolatedDeclaration: isolatedDe
|
|
|
574
578
|
let programs = [];
|
|
575
579
|
return {
|
|
576
580
|
name: "rolldown-plugin-dts:generate",
|
|
577
|
-
buildStart(options) {
|
|
581
|
+
async buildStart(options) {
|
|
578
582
|
if (!compilerOptions) {
|
|
579
583
|
const { config } = getTsconfig(options.cwd) || {};
|
|
580
584
|
compilerOptions = config?.compilerOptions;
|
|
@@ -583,12 +587,10 @@ function createGeneratePlugin({ compilerOptions, isolatedDeclaration: isolatedDe
|
|
|
583
587
|
if (isolatedDeclaration$1 === true) isolatedDeclaration$1 = {};
|
|
584
588
|
if (isolatedDeclaration$1 && isolatedDeclaration$1.stripInternal == null) isolatedDeclaration$1.stripInternal = !!compilerOptions?.stripInternal;
|
|
585
589
|
if (!isolatedDeclaration$1) initTs();
|
|
586
|
-
if (!Array.isArray(options.input)) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
inputAliasMap.set(id, fileName);
|
|
591
|
-
}
|
|
590
|
+
if (!Array.isArray(options.input)) for (const [name, id] of Object.entries(options.input)) {
|
|
591
|
+
let resolved = await this.resolve(id, void 0, { skipSelf: true });
|
|
592
|
+
resolved ||= await this.resolve(`./${id}`, void 0, { skipSelf: true });
|
|
593
|
+
inputAliasMap.set(resolved?.id || id, name);
|
|
592
594
|
}
|
|
593
595
|
},
|
|
594
596
|
outputOptions(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-dts",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "A Rolldown plugin to bundle dts files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"debug": "^4.4.0",
|
|
41
|
-
"dts-resolver": "^0.1.
|
|
41
|
+
"dts-resolver": "^0.1.1",
|
|
42
42
|
"get-tsconfig": "^4.10.0",
|
|
43
43
|
"magic-string-ast": "^0.9.1",
|
|
44
|
-
"oxc-parser": "^0.
|
|
45
|
-
"oxc-transform": "^0.
|
|
44
|
+
"oxc-parser": "^0.64.0",
|
|
45
|
+
"oxc-transform": "^0.64.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@sxzz/eslint-config": "^6.1.1",
|
|
49
49
|
"@sxzz/prettier-config": "^2.2.1",
|
|
50
|
-
"@sxzz/test-utils": "^0.5.
|
|
50
|
+
"@sxzz/test-utils": "^0.5.5",
|
|
51
51
|
"@types/debug": "^4.1.12",
|
|
52
52
|
"@types/diff": "^7.0.2",
|
|
53
|
-
"@types/node": "^22.14.
|
|
53
|
+
"@types/node": "^22.14.1",
|
|
54
54
|
"bumpp": "^10.1.0",
|
|
55
55
|
"diff": "^7.0.0",
|
|
56
56
|
"eslint": "^9.24.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"prettier": "^3.5.3",
|
|
59
59
|
"rolldown": "^1.0.0-beta.7",
|
|
60
60
|
"rollup-plugin-dts": "^6.2.1",
|
|
61
|
-
"tsdown": "^0.8.0
|
|
61
|
+
"tsdown": "^0.8.0",
|
|
62
62
|
"tsx": "^4.19.3",
|
|
63
63
|
"typescript": "^5.8.3",
|
|
64
64
|
"vitest": "^3.1.1"
|