rolldown-plugin-dts 0.17.0 → 0.17.1
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/dist/index.js +28 -5
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -364,7 +364,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault }) {
|
|
|
364
364
|
bindings.push(binding);
|
|
365
365
|
decl.id = binding;
|
|
366
366
|
}
|
|
367
|
-
const params =
|
|
367
|
+
const params = collectParams(decl);
|
|
368
368
|
const deps = collectDependencies(decl, namespaceStmts);
|
|
369
369
|
if (decl !== stmt) decl.leadingComments = stmt.leadingComments;
|
|
370
370
|
const symbolId = registerSymbol({
|
|
@@ -374,7 +374,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault }) {
|
|
|
374
374
|
params
|
|
375
375
|
});
|
|
376
376
|
const symbolIdNode = t.numericLiteral(symbolId);
|
|
377
|
-
const depsNode = t.arrowFunctionExpression(params.map((
|
|
377
|
+
const depsNode = t.arrowFunctionExpression(params.map(({ name }) => t.identifier(name)), t.arrayExpression(deps));
|
|
378
378
|
const sideEffectNode = sideEffect && t.callExpression(t.identifier("sideEffect"), [bindings[0]]);
|
|
379
379
|
const runtimeArrayNode = runtimeBindingArrayExpression(sideEffectNode ? [
|
|
380
380
|
symbolIdNode,
|
|
@@ -445,9 +445,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault }) {
|
|
|
445
445
|
overwriteNode(original.bindings[i], transformedBinding);
|
|
446
446
|
}
|
|
447
447
|
const transformedParams = depsFn.params;
|
|
448
|
-
for (
|
|
449
|
-
const
|
|
450
|
-
|
|
448
|
+
for (const [i, transformedParam] of transformedParams.entries()) {
|
|
449
|
+
const transformedName = transformedParam.name;
|
|
450
|
+
for (const originalTypeParam of original.params[i].typeParams) originalTypeParam.name = transformedName;
|
|
451
451
|
}
|
|
452
452
|
const transformedDeps = depsFn.body.elements;
|
|
453
453
|
for (let i = 0; i < original.deps.length; i++) {
|
|
@@ -494,6 +494,29 @@ function createFakeJsPlugin({ sourcemap, cjsDefault }) {
|
|
|
494
494
|
function getSymbol(symbolId) {
|
|
495
495
|
return symbolMap.get(symbolId);
|
|
496
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Collects all TSTypeParameter nodes from the given node and groups them by
|
|
499
|
+
* their name. One name can associate with one or more type parameters. These
|
|
500
|
+
* names will be used as the parameter name in the generated JavaScript
|
|
501
|
+
* dependency function.
|
|
502
|
+
*/
|
|
503
|
+
function collectParams(node) {
|
|
504
|
+
const typeParams = [];
|
|
505
|
+
walk(node, { leave(node$1) {
|
|
506
|
+
if ("typeParameters" in node$1 && node$1.typeParameters?.type === "TSTypeParameterDeclaration") typeParams.push(...node$1.typeParameters.params);
|
|
507
|
+
} });
|
|
508
|
+
const paramMap = /* @__PURE__ */ new Map();
|
|
509
|
+
for (const typeParam of typeParams) {
|
|
510
|
+
const name = typeParam.name;
|
|
511
|
+
const group = paramMap.get(name);
|
|
512
|
+
if (group) group.push(typeParam);
|
|
513
|
+
else paramMap.set(name, [typeParam]);
|
|
514
|
+
}
|
|
515
|
+
return Array.from(paramMap.entries()).map(([name, typeParams$1]) => ({
|
|
516
|
+
name,
|
|
517
|
+
typeParams: typeParams$1
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
497
520
|
function collectDependencies(node, namespaceStmts) {
|
|
498
521
|
const deps = /* @__PURE__ */ new Set();
|
|
499
522
|
const seen = /* @__PURE__ */ new Set();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-dts",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "A Rolldown plugin to generate and bundle dts files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -61,24 +61,24 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@babel/generator": "^7.28.
|
|
65
|
-
"@babel/parser": "^7.28.
|
|
66
|
-
"@babel/types": "^7.28.
|
|
64
|
+
"@babel/generator": "^7.28.5",
|
|
65
|
+
"@babel/parser": "^7.28.5",
|
|
66
|
+
"@babel/types": "^7.28.5",
|
|
67
67
|
"ast-kit": "^2.1.3",
|
|
68
68
|
"birpc": "^2.6.1",
|
|
69
69
|
"debug": "^4.4.3",
|
|
70
70
|
"dts-resolver": "^2.1.2",
|
|
71
71
|
"get-tsconfig": "^4.13.0",
|
|
72
|
-
"magic-string": "^0.30.
|
|
72
|
+
"magic-string": "^0.30.21"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@sxzz/eslint-config": "^7.2.7",
|
|
76
76
|
"@sxzz/prettier-config": "^2.2.4",
|
|
77
|
-
"@sxzz/test-utils": "^0.5.
|
|
77
|
+
"@sxzz/test-utils": "^0.5.12",
|
|
78
78
|
"@types/babel__generator": "^7.27.0",
|
|
79
79
|
"@types/debug": "^4.1.12",
|
|
80
80
|
"@types/node": "^24.9.1",
|
|
81
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
81
|
+
"@typescript/native-preview": "7.0.0-dev.20251024.1",
|
|
82
82
|
"@volar/typescript": "^2.4.23",
|
|
83
83
|
"@vue/language-core": "^3.1.1",
|
|
84
84
|
"arktype": "^2.1.23",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"tinyglobby": "^0.2.15",
|
|
94
94
|
"tsdown": "^0.15.9",
|
|
95
95
|
"typescript": "^5.9.3",
|
|
96
|
-
"vitest": "^4.0.
|
|
96
|
+
"vitest": "^4.0.3",
|
|
97
97
|
"vue": "^3.5.22",
|
|
98
98
|
"vue-tsc": "^3.1.1"
|
|
99
99
|
},
|