rolldown-plugin-dts 0.18.1 → 0.18.3

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.
Files changed (2) hide show
  1. package/dist/index.mjs +58 -33
  2. package/package.json +35 -35
package/dist/index.mjs CHANGED
@@ -336,43 +336,61 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
336
336
  function collectDependencies(node, namespaceStmts) {
337
337
  const deps = /* @__PURE__ */ new Set();
338
338
  const seen = /* @__PURE__ */ new Set();
339
- walkAST(node, { leave(node$1) {
340
- if (node$1.type === "ExportNamedDeclaration") {
341
- for (const specifier of node$1.specifiers) if (specifier.type === "ExportSpecifier") addDependency(specifier.local);
342
- } else if (node$1.type === "TSInterfaceDeclaration" && node$1.extends) for (const heritage of node$1.extends || []) addDependency(TSEntityNameToRuntime(heritage.expression));
343
- else if (node$1.type === "ClassDeclaration") {
344
- if (node$1.superClass) addDependency(node$1.superClass);
345
- if (node$1.implements) for (const implement of node$1.implements) addDependency(TSEntityNameToRuntime(implement.expression));
346
- } else if (isTypeOf(node$1, [
347
- "ObjectMethod",
348
- "ObjectProperty",
349
- "ClassProperty",
350
- "TSPropertySignature",
351
- "TSDeclareMethod"
352
- ])) {
353
- if (node$1.computed && isReferenceId(node$1.key)) addDependency(node$1.key);
354
- if ("value" in node$1 && isReferenceId(node$1.value)) addDependency(node$1.value);
355
- } else switch (node$1.type) {
356
- case "TSTypeReference":
357
- addDependency(TSEntityNameToRuntime(node$1.typeName));
358
- break;
359
- case "TSTypeQuery":
360
- if (seen.has(node$1.exprName)) return;
361
- if (node$1.exprName.type === "TSImportType") break;
362
- addDependency(TSEntityNameToRuntime(node$1.exprName));
363
- break;
364
- case "TSImportType": {
365
- seen.add(node$1);
366
- const source = node$1.argument;
367
- const imported = node$1.qualifier;
368
- addDependency(importNamespace(node$1, imported, source, namespaceStmts));
369
- break;
339
+ const inferredStack = [];
340
+ let currentInferred = /* @__PURE__ */ new Set();
341
+ function isInferred(node$1) {
342
+ return node$1.type === "Identifier" && currentInferred.has(node$1.name);
343
+ }
344
+ walkAST(node, {
345
+ enter(node$1) {
346
+ if (node$1.type === "TSConditionalType") {
347
+ const inferred = collectInferredNames(node$1.extendsType);
348
+ inferredStack.push(inferred);
349
+ }
350
+ },
351
+ leave(node$1, parent) {
352
+ if (node$1.type === "TSConditionalType") inferredStack.pop();
353
+ else if (parent?.type === "TSConditionalType") {
354
+ const trueBranch = parent.trueType === node$1;
355
+ currentInferred = new Set((trueBranch ? inferredStack : inferredStack.slice(0, -1)).flat());
356
+ } else currentInferred = /* @__PURE__ */ new Set();
357
+ if (node$1.type === "ExportNamedDeclaration") {
358
+ for (const specifier of node$1.specifiers) if (specifier.type === "ExportSpecifier") addDependency(specifier.local);
359
+ } else if (node$1.type === "TSInterfaceDeclaration" && node$1.extends) for (const heritage of node$1.extends || []) addDependency(TSEntityNameToRuntime(heritage.expression));
360
+ else if (node$1.type === "ClassDeclaration") {
361
+ if (node$1.superClass) addDependency(node$1.superClass);
362
+ if (node$1.implements) for (const implement of node$1.implements) addDependency(TSEntityNameToRuntime(implement.expression));
363
+ } else if (isTypeOf(node$1, [
364
+ "ObjectMethod",
365
+ "ObjectProperty",
366
+ "ClassProperty",
367
+ "TSPropertySignature",
368
+ "TSDeclareMethod"
369
+ ])) {
370
+ if (node$1.computed && isReferenceId(node$1.key)) addDependency(node$1.key);
371
+ if ("value" in node$1 && isReferenceId(node$1.value)) addDependency(node$1.value);
372
+ } else switch (node$1.type) {
373
+ case "TSTypeReference":
374
+ addDependency(TSEntityNameToRuntime(node$1.typeName));
375
+ break;
376
+ case "TSTypeQuery":
377
+ if (seen.has(node$1.exprName)) return;
378
+ if (node$1.exprName.type === "TSImportType") break;
379
+ addDependency(TSEntityNameToRuntime(node$1.exprName));
380
+ break;
381
+ case "TSImportType": {
382
+ seen.add(node$1);
383
+ const source = node$1.argument;
384
+ const imported = node$1.qualifier;
385
+ addDependency(importNamespace(node$1, imported, source, namespaceStmts));
386
+ break;
387
+ }
370
388
  }
371
389
  }
372
- } });
390
+ });
373
391
  return Array.from(deps);
374
392
  function addDependency(node$1) {
375
- if (isThisExpression(node$1)) return;
393
+ if (isThisExpression(node$1) || isInferred(node$1)) return;
376
394
  deps.add(node$1);
377
395
  }
378
396
  }
@@ -402,6 +420,13 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
402
420
  };
403
421
  }
404
422
  }
423
+ function collectInferredNames(node) {
424
+ const inferred = [];
425
+ walkAST(node, { enter(node$1) {
426
+ if (node$1.type === "TSInferType" && node$1.typeParameter) inferred.push(node$1.typeParameter.name);
427
+ } });
428
+ return inferred;
429
+ }
405
430
  const REFERENCE_RE = /\/\s*<reference\s+(?:path|types)=/;
406
431
  function collectReferenceDirectives(comment, negative = false) {
407
432
  return comment.filter((c) => REFERENCE_RE.test(c.value) !== negative);
package/package.json CHANGED
@@ -1,8 +1,19 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.18.1",
4
- "description": "A Rolldown plugin to generate and bundle dts files.",
5
3
  "type": "module",
4
+ "version": "0.18.3",
5
+ "description": "A Rolldown plugin to generate and bundle dts files.",
6
+ "author": "Kevin Deng <sxzz@sxzz.moe>",
7
+ "license": "MIT",
8
+ "funding": "https://github.com/sponsors/sxzz",
9
+ "homepage": "https://github.com/sxzz/rolldown-plugin-dts#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/sxzz/rolldown-plugin-dts.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/sxzz/rolldown-plugin-dts/issues"
16
+ },
6
17
  "keywords": [
7
18
  "rolldown",
8
19
  "plugin",
@@ -11,23 +22,6 @@
11
22
  "vue",
12
23
  "jsdoc"
13
24
  ],
14
- "license": "MIT",
15
- "homepage": "https://github.com/sxzz/rolldown-plugin-dts#readme",
16
- "bugs": {
17
- "url": "https://github.com/sxzz/rolldown-plugin-dts/issues"
18
- },
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://github.com/sxzz/rolldown-plugin-dts.git"
22
- },
23
- "author": "Kevin Deng <sxzz@sxzz.moe>",
24
- "funding": "https://github.com/sponsors/sxzz",
25
- "files": [
26
- "dist"
27
- ],
28
- "main": "./dist/index.mjs",
29
- "module": "./dist/index.mjs",
30
- "types": "./dist/index.d.mts",
31
25
  "exports": {
32
26
  ".": "./dist/index.mjs",
33
27
  "./filename": "./dist/filename.mjs",
@@ -36,9 +30,18 @@
36
30
  "./tsc-worker": "./dist/tsc-worker.mjs",
37
31
  "./package.json": "./package.json"
38
32
  },
33
+ "main": "./dist/index.mjs",
34
+ "module": "./dist/index.mjs",
35
+ "types": "./dist/index.d.mts",
36
+ "files": [
37
+ "dist"
38
+ ],
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
+ "engines": {
43
+ "node": ">=20.19.0"
44
+ },
42
45
  "peerDependencies": {
43
46
  "@ts-macro/tsc": "^0.3.6",
44
47
  "@typescript/native-preview": ">=7.0.0-dev.20250601.1",
@@ -65,39 +68,36 @@
65
68
  "@babel/parser": "^7.28.5",
66
69
  "@babel/types": "^7.28.5",
67
70
  "ast-kit": "^2.2.0",
68
- "birpc": "^2.8.0",
71
+ "birpc": "^3.0.0",
69
72
  "dts-resolver": "^2.1.3",
70
73
  "get-tsconfig": "^4.13.0",
71
74
  "magic-string": "^0.30.21",
72
75
  "obug": "^2.1.1"
73
76
  },
74
77
  "devDependencies": {
75
- "@sxzz/eslint-config": "^7.3.2",
76
- "@sxzz/prettier-config": "^2.2.5",
78
+ "@sxzz/eslint-config": "^7.4.1",
79
+ "@sxzz/prettier-config": "^2.2.6",
77
80
  "@sxzz/test-utils": "^0.5.13",
78
81
  "@types/babel__generator": "^7.27.0",
79
82
  "@types/node": "^24.10.1",
80
- "@typescript/native-preview": "7.0.0-dev.20251125.1",
83
+ "@typescript/native-preview": "7.0.0-dev.20251204.1",
81
84
  "@volar/typescript": "^2.4.26",
82
85
  "@vue/language-core": "^3.1.5",
83
- "arktype": "^2.1.27",
84
- "bumpp": "^10.3.1",
86
+ "arktype": "^2.1.28",
87
+ "bumpp": "^10.3.2",
85
88
  "diff": "^8.0.2",
86
89
  "eslint": "^9.39.1",
87
- "prettier": "^3.6.2",
88
- "rolldown": "^1.0.0-beta.51",
89
- "rolldown-plugin-require-cjs": "^0.3.1",
90
- "rollup-plugin-dts": "^6.2.3",
90
+ "prettier": "^3.7.4",
91
+ "rolldown": "^1.0.0-beta.53",
92
+ "rolldown-plugin-require-cjs": "^0.3.3",
93
+ "rollup-plugin-dts": "^6.3.0",
91
94
  "tinyglobby": "^0.2.15",
92
- "tsdown": "^0.16.6",
95
+ "tsdown": "^0.17.0",
93
96
  "typescript": "^5.9.3",
94
- "vitest": "^4.0.13",
97
+ "vitest": "^4.0.15",
95
98
  "vue": "^3.5.25",
96
99
  "vue-tsc": "^3.1.5"
97
100
  },
98
- "engines": {
99
- "node": ">=20.19.0"
100
- },
101
101
  "prettier": "@sxzz/prettier-config",
102
102
  "scripts": {
103
103
  "lint": "eslint --cache .",
@@ -105,7 +105,7 @@
105
105
  "build": "tsdown",
106
106
  "dev": "tsdown --watch",
107
107
  "test": "vitest",
108
- "typecheck": "tsc --noEmit",
108
+ "typecheck": "tsgo --noEmit",
109
109
  "format": "prettier --cache --write .",
110
110
  "release": "bumpp"
111
111
  }