rolldown-plugin-dts 0.22.5 → 0.23.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/README.md CHANGED
@@ -8,7 +8,7 @@ A Rolldown plugin to generate and bundle dts files.
8
8
 
9
9
  ## Install
10
10
 
11
- Requires **`rolldown@1.0.0-rc.3`** or later.
11
+ Requires **`rolldown@1.0.0-rc.12`** or later.
12
12
 
13
13
  ```bash
14
14
  npm i -D rolldown-plugin-dts
@@ -26,4 +26,4 @@ function replaceTemplateName(template, name) {
26
26
  return template.replaceAll("[name]", name);
27
27
  }
28
28
  //#endregion
29
- export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn };
29
+ export { RE_JSON as a, RE_TS as c, filename_js_to_dts as d, filename_to_dts as f, RE_JS as i, RE_VUE as l, resolveTemplateFn as m, RE_DTS as n, RE_NODE_MODULES as o, replaceTemplateName as p, RE_DTS_MAP as r, RE_ROLLDOWN_RUNTIME as s, RE_CSS as t, filename_dts_to as u };
@@ -1,4 +1,4 @@
1
- import { r as TscContext } from "./context-Cc-Tkynb.mjs";
1
+ import { r as TscContext } from "./context-3rlTPR48.mjs";
2
2
  import { SourceMapInput } from "rolldown";
3
3
  import { TsConfigJson } from "get-tsconfig";
4
4
  import ts from "typescript";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn } from "./filename.mjs";
1
+ import { a as RE_JSON, c as RE_TS, d as filename_js_to_dts, f as filename_to_dts, i as RE_JS, l as RE_VUE, m as resolveTemplateFn, n as RE_DTS, o as RE_NODE_MODULES, p as replaceTemplateName, r as RE_DTS_MAP, s as RE_ROLLDOWN_RUNTIME, t as RE_CSS, u as filename_dts_to } from "./filename-DQnUJlio.mjs";
2
2
  import { createContext, globalContext, invalidateContextFile } from "./tsc-context.mjs";
3
3
  import { createDebug } from "obug";
4
4
  import { importerId, include } from "rolldown/filter";
@@ -94,12 +94,17 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
94
94
  }
95
95
  };
96
96
  function transform(code, id) {
97
- const file = parse(code, {
98
- plugins: [["typescript", { dts: true }], "decoratorAutoAccessors"],
99
- sourceType: "module",
100
- errorRecovery: true,
101
- createParenthesizedExpressions: true
102
- });
97
+ let file;
98
+ try {
99
+ file = parse(code, {
100
+ plugins: [["typescript", { dts: true }], "decoratorAutoAccessors"],
101
+ sourceType: "module",
102
+ errorRecovery: true,
103
+ createParenthesizedExpressions: true
104
+ });
105
+ } catch (error) {
106
+ throw new Error(`Failed to parse ${id}. This may be caused by a syntax error in the declaration file or a bug in the plugin. Please report this issue to https://github.com/sxzz/rolldown-plugin-dts\n${error}`, { cause: error });
107
+ }
103
108
  const { program, comments } = file;
104
109
  const typeOnlyIds = [];
105
110
  const identifierMap = Object.create(null);
@@ -216,7 +221,12 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
216
221
  const ids = typeOnlyMap.get(module);
217
222
  if (ids) typeOnlyIds.push(...ids);
218
223
  }
219
- const file = parse(code, { sourceType: "module" });
224
+ let file;
225
+ try {
226
+ file = parse(code, { sourceType: "module" });
227
+ } catch (error) {
228
+ throw new Error(`Failed to parse generated code for chunk ${chunk.fileName}. This may be caused by a bug in the plugin. Please report this issue to https://github.com/sxzz/rolldown-plugin-dts\n${error}`, { cause: error });
229
+ }
220
230
  const { program } = file;
221
231
  program.body = patchTsNamespace(program.body);
222
232
  program.body = patchReExport(program.body);
@@ -391,7 +401,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
391
401
  }
392
402
  function importNamespace(node, imported, source, namespaceStmts, identifierMap) {
393
403
  const sourceText = source.value.replaceAll(/\W/g, "_");
394
- const localName = isIdentifierName(source.value) ? source.value : `${sourceText}${getIdentifierIndex(identifierMap, sourceText)}`;
404
+ const localName = `_$${isIdentifierName(source.value) ? source.value : `${sourceText}${getIdentifierIndex(identifierMap, sourceText)}`}`;
395
405
  let local = t.identifier(localName);
396
406
  if (namespaceStmts.has(source.value)) local = namespaceStmts.get(source.value).local;
397
407
  else namespaceStmts.set(source.value, {
@@ -1010,7 +1020,7 @@ function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolver, sideEffe
1010
1020
  debug$1("Rolldown resolution for dts import %O from %O: %O", id, importer, rolldownResolution);
1011
1021
  if (rolldownResolution?.external) {
1012
1022
  debug$1("Rolldown marked dts import as external:", id);
1013
- return external;
1023
+ return rolldownResolution;
1014
1024
  }
1015
1025
  const dtsResolution = await resolveDtsPath(id, importer, rolldownResolution);
1016
1026
  debug$1("Dts resolution for dts import %O from %O: %O", id, importer, dtsResolution);
@@ -1043,7 +1053,7 @@ function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolver, sideEffe
1043
1053
  async function resolveDtsPath(id, importer, rolldownResolution) {
1044
1054
  let dtsPath;
1045
1055
  if (resolver === "tsc") {
1046
- const { tscResolve } = await import("./resolver-BUWpVKW_.mjs");
1056
+ const { tscResolve } = await import("./resolver-DkvdaW3s.mjs");
1047
1057
  dtsPath = tscResolve(id, importer, cwd, tsconfig, tsconfigRaw);
1048
1058
  } else dtsPath = baseDtsResolver(id, importer);
1049
1059
  debug$1("Using %s for dts import: %O -> %O", resolver, id, dtsPath);
@@ -1,4 +1,5 @@
1
1
  import { ChunkFileNamesFunction, PreRenderedChunk } from "rolldown";
2
+ import { parseTsconfig } from "get-tsconfig";
2
3
 
3
4
  //#region src/filename.d.ts
4
5
  declare const RE_JS: RegExp;
@@ -16,4 +17,4 @@ declare function filename_dts_to(id: string, ext: "js" | "ts"): string;
16
17
  declare function resolveTemplateFn(fn: string | ChunkFileNamesFunction, chunk: PreRenderedChunk): string;
17
18
  declare function replaceTemplateName(template: string, name: string): string;
18
19
  //#endregion
19
- export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn };
20
+ export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, parseTsconfig, replaceTemplateName, resolveTemplateFn };
@@ -0,0 +1,3 @@
1
+ import { a as RE_JSON, c as RE_TS, d as filename_js_to_dts, f as filename_to_dts, i as RE_JS, l as RE_VUE, m as resolveTemplateFn, n as RE_DTS, o as RE_NODE_MODULES, p as replaceTemplateName, r as RE_DTS_MAP, s as RE_ROLLDOWN_RUNTIME, t as RE_CSS, u as filename_dts_to } from "./filename-DQnUJlio.mjs";
2
+ import { parseTsconfig } from "get-tsconfig";
3
+ export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, parseTsconfig, replaceTemplateName, resolveTemplateFn };
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __cjs_createRequire } from "node:module";
2
2
  const __cjs_require = __cjs_createRequire(import.meta.url);
3
- import { RE_DTS, RE_DTS_MAP } from "./filename.mjs";
3
+ import { n as RE_DTS, r as RE_DTS_MAP } from "./filename-DQnUJlio.mjs";
4
4
  import { globalContext } from "./tsc-context.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import { createDebug } from "obug";
@@ -1,2 +1,2 @@
1
- import { a as globalContext, i as createContext, n as SourceFileToProjectMap, o as invalidateContextFile, r as TscContext, t as ParsedProject } from "./context-Cc-Tkynb.mjs";
1
+ import { a as globalContext, i as createContext, n as SourceFileToProjectMap, o as invalidateContextFile, r as TscContext, t as ParsedProject } from "./context-3rlTPR48.mjs";
2
2
  export { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile };
@@ -1,4 +1,4 @@
1
- import { t as tscEmit } from "./index-lpAqB_wE.mjs";
1
+ import { t as tscEmit } from "./index-DAUYR4Qd.mjs";
2
2
 
3
3
  //#region src/tsc/worker.d.ts
4
4
  declare const functions: {
@@ -1,4 +1,4 @@
1
- import { t as tscEmit } from "./tsc-Dh95OfBG.mjs";
1
+ import { t as tscEmit } from "./tsc-8hYVvCE4.mjs";
2
2
  import process from "node:process";
3
3
  import { createBirpc } from "birpc";
4
4
  //#region src/tsc/worker.ts
package/dist/tsc.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-lpAqB_wE.mjs";
1
+ import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-DAUYR4Qd.mjs";
2
2
  export { TscModule, TscOptions, TscResult, tscEmit };
package/dist/tsc.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as tscEmit } from "./tsc-Dh95OfBG.mjs";
1
+ import { t as tscEmit } from "./tsc-8hYVvCE4.mjs";
2
2
  export { tscEmit };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
3
  "type": "module",
4
- "version": "0.22.5",
4
+ "version": "0.23.1",
5
5
  "description": "A Rolldown plugin to generate and bundle dts files.",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "exports": {
26
26
  ".": "./dist/index.mjs",
27
- "./filename": "./dist/filename.mjs",
27
+ "./internal": "./dist/internal.mjs",
28
28
  "./tsc": "./dist/tsc.mjs",
29
29
  "./tsc-context": "./dist/tsc-context.mjs",
30
30
  "./tsc-worker": "./dist/tsc-worker.mjs",
@@ -42,9 +42,9 @@
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@ts-macro/tsc": "^0.3.6",
45
- "@typescript/native-preview": ">=7.0.0-dev.20250601.1",
46
- "rolldown": "^1.0.0-rc.3",
47
- "typescript": "^5.0.0 || ^6.0.0-beta",
45
+ "@typescript/native-preview": ">=7.0.0-dev.20260325.1",
46
+ "rolldown": "^1.0.0-rc.12",
47
+ "typescript": "^5.0.0 || ^6.0.0",
48
48
  "vue-tsc": "~3.2.0"
49
49
  },
50
50
  "peerDependenciesMeta": {
@@ -62,14 +62,14 @@
62
62
  }
63
63
  },
64
64
  "dependencies": {
65
- "@babel/generator": "8.0.0-rc.2",
66
- "@babel/helper-validator-identifier": "8.0.0-rc.2",
67
- "@babel/parser": "8.0.0-rc.2",
68
- "@babel/types": "8.0.0-rc.2",
65
+ "@babel/generator": "8.0.0-rc.3",
66
+ "@babel/helper-validator-identifier": "8.0.0-rc.3",
67
+ "@babel/parser": "8.0.0-rc.3",
68
+ "@babel/types": "8.0.0-rc.3",
69
69
  "ast-kit": "^3.0.0-beta.1",
70
70
  "birpc": "^4.0.0",
71
71
  "dts-resolver": "^2.1.3",
72
- "get-tsconfig": "^4.13.6",
72
+ "get-tsconfig": "^4.13.7",
73
73
  "obug": "^2.1.1"
74
74
  },
75
75
  "devDependencies": {
@@ -77,29 +77,29 @@
77
77
  "@sxzz/eslint-config": "^7.8.3",
78
78
  "@sxzz/prettier-config": "^2.3.1",
79
79
  "@sxzz/test-utils": "^0.5.15",
80
- "@types/node": "^25.4.0",
81
- "@typescript/native-preview": "7.0.0-dev.20260311.1",
80
+ "@types/node": "^25.5.0",
81
+ "@typescript/native-preview": "7.0.0-dev.20260325.1",
82
82
  "@volar/typescript": "^2.4.28",
83
- "@vue/language-core": "^3.2.5",
83
+ "@vue/language-core": "^3.2.6",
84
84
  "arktype": "^2.2.0",
85
- "bumpp": "^10.4.1",
86
- "diff": "^8.0.3",
87
- "eslint": "^10.0.3",
85
+ "bumpp": "^11.0.1",
86
+ "diff": "^8.0.4",
87
+ "eslint": "^10.1.0",
88
88
  "prettier": "^3.8.1",
89
- "rolldown": "^1.0.0-rc.9",
89
+ "rolldown": "^1.0.0-rc.12",
90
90
  "rolldown-plugin-dts-snapshot": "^0.4.0",
91
91
  "rolldown-plugin-require-cjs": "^0.4.0",
92
- "rollup-plugin-dts": "^6.3.0",
92
+ "rollup-plugin-dts": "^6.4.1",
93
93
  "tinyglobby": "^0.2.15",
94
- "tsdown": "^0.21.1",
95
- "typescript": "6.0.0-dev.20260301",
96
- "vitest": "^4.0.18",
97
- "vue": "^3.5.30",
98
- "vue-tsc": "^3.2.5",
94
+ "tsdown": "^0.21.5",
95
+ "typescript": "^6.0.2",
96
+ "vitest": "^4.1.1",
97
+ "vue": "^3.5.31",
98
+ "vue-tsc": "^3.2.6",
99
99
  "zod": "^4.3.6"
100
100
  },
101
101
  "resolutions": {
102
- "rolldown": "^1.0.0-rc.9"
102
+ "rolldown": "^1.0.0-rc.12"
103
103
  },
104
104
  "prettier": "@sxzz/prettier-config",
105
105
  "scripts": {