rolldown-plugin-dts 0.27.0 → 0.27.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 CHANGED
@@ -188,7 +188,7 @@ guaranteeing that all type definitions are generated from scratch.
188
188
  `invalidateContextFile` API can be used to clear invalidated files from the context.
189
189
 
190
190
  ```ts
191
- import { globalContext, invalidateContextFile } from 'rolldown-plugin-dts/tsc'
191
+ import { globalContext, invalidateContextFile } from 'rolldown-plugin-dts/tsc-context'
192
192
  invalidateContextFile(globalContext, 'src/foo.ts')
193
193
  ```
194
194
 
@@ -210,13 +210,13 @@ This option is automatically enabled when `isolatedDeclarations` in `compilerOpt
210
210
  ### TypeScript Go
211
211
 
212
212
  > [!WARNING]
213
- > This feature is experimental and not yet recommended for production environments.
213
+ > TypeScript 7.0 does not yet have a stable API and is experimental. This feature is not yet recommended for production environments, and some options will be unavailable.
214
214
 
215
215
  #### `tsgo`
216
216
 
217
217
  **[Experimental]** Enables DTS generation using [`tsgo`](https://github.com/microsoft/typescript-go).
218
218
 
219
- To use this option, ensure that `@typescript/native-preview` is installed as a dependency.
219
+ This is automatically enabled when the native TypeScript compiler (v7+) is installed as the `typescript` package. Otherwise, ensure that `@typescript/native-preview` is installed as a dependency.
220
220
 
221
221
  `tsconfigRaw` and `compilerOptions` options will be ignored when this option is enabled.
222
222
 
package/dist/index.d.mts CHANGED
@@ -177,11 +177,15 @@ interface Options extends GeneralOptions, TscOptions {
177
177
  /**
178
178
  * **[Experimental]** Enables DTS generation using `tsgo`.
179
179
  *
180
- * To use this option, make sure `@typescript/native-preview` is installed as a dependency,
181
- * or provide a custom path to the `tsgo` binary using the `path` option.
182
- *
183
- * **Note:** This option is not yet recommended for production environments.
184
- * `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
180
+ * This is automatically enabled when the TypeScript Go compiler (v7+) is
181
+ * installed as the `typescript` package. Otherwise, make sure
182
+ * `@typescript/native-preview` is installed as a dependency, or provide a
183
+ * custom path to the `tsgo` binary using the `path` option.
184
+ *
185
+ * **Note:** TypeScript 7.0 does not yet have a stable API and is experimental.
186
+ * This option is not yet recommended for production environments, and some
187
+ * options (such as `tsconfigRaw` and `isolatedDeclarations`) will be
188
+ * unavailable when it is enabled.
185
189
  *
186
190
  *
187
191
  * ```ts
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
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-BR9JpwkC.mjs";
2
2
  import { createContext, globalContext, invalidateContextFile } from "./tsc-context.mjs";
3
+ import { createRequire } from "node:module";
3
4
  import { createDebug } from "obug";
4
5
  import { importerId, include } from "rolldown/filter";
5
6
  import { b, is } from "yuku-ast";
@@ -646,7 +647,7 @@ function isReferenceId(node) {
646
647
  return is.oneOf(node, ["Identifier", "MemberExpression"]);
647
648
  }
648
649
  function isHelperImport(node) {
649
- return node.type === "ImportDeclaration" && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.imported.type === "Identifier" && ["__exportAll", "__reExport"].includes(spec.local.name));
650
+ return node.type === "ImportDeclaration" && node.specifiers.length && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.imported.type === "Identifier" && ["__exportAll", "__reExport"].includes(spec.local.name));
650
651
  }
651
652
  /**
652
653
  * patch `.d.ts` suffix in import source to `.js`
@@ -765,14 +766,29 @@ function getIdentifierIndex(identifierMap, name) {
765
766
  }
766
767
  //#endregion
767
768
  //#region src/tsgo.ts
769
+ const require = createRequire(import.meta.url);
768
770
  const debug$3 = createDebug("rolldown-plugin-dts:tsgo");
771
+ function getTypeScriptMajor() {
772
+ try {
773
+ const { version } = require("typescript/package.json");
774
+ const major = +version.split(".", 1)[0];
775
+ return Number.isNaN(major) ? void 0 : major;
776
+ } catch {
777
+ return;
778
+ }
779
+ }
780
+ function isTsgo() {
781
+ const major = getTypeScriptMajor();
782
+ return major != null && major >= 7;
783
+ }
769
784
  const spawnAsync = (...args) => new Promise((resolve, reject) => {
770
785
  const child = spawn(...args);
771
786
  child.on("close", () => resolve());
772
787
  child.on("error", (error) => reject(error));
773
788
  });
774
789
  async function getTsgoPathFromNodeModules() {
775
- const tsgoPkg = import.meta.resolve("@typescript/native-preview/package.json");
790
+ const pkgName = isTsgo() ? "typescript" : "@typescript/native-preview";
791
+ const tsgoPkg = import.meta.resolve(`${pkgName}/package.json`);
776
792
  const { default: getExePath } = await import(new URL("lib/getExePath.js", tsgoPkg).href);
777
793
  return getExePath();
778
794
  }
@@ -1093,9 +1109,11 @@ function collectJsonExports(code) {
1093
1109
  //#endregion
1094
1110
  //#region src/options.ts
1095
1111
  let warnedTsgo = false;
1096
- function resolveOptions({ entry, cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap, resolver = "oxc", cjsDefault = false, sideEffects = false, build = false, incremental = false, vue = false, tsMacro = false, parallel = false, eager = false, newContext = false, emitJs, oxc, tsgo = false }) {
1112
+ function resolveOptions({ entry, cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap, resolver = "oxc", cjsDefault = false, sideEffects = false, build = false, incremental = false, vue = false, tsMacro = false, parallel = false, eager = false, newContext = false, emitJs, oxc, tsgo }) {
1113
+ if (tsgo == null) tsgo = isTsgo() && !vue && !tsMacro && !oxc;
1097
1114
  if (tsgo === true) tsgo = {};
1098
1115
  else if (typeof tsgo === "object" && tsgo.enabled === false) tsgo = false;
1116
+ if (!tsgo && isTsgo()) throw new Error("[rolldown-plugin-dts] TypeScript 7.0 is installed, but the `tsgo` option is disabled. Please enable it to use TypeScript 7.0 features.");
1099
1117
  let resolvedTsconfig;
1100
1118
  if (tsconfig === true || tsconfig == null) {
1101
1119
  const { config, path } = getTsconfig(cwd) || {};
@@ -1132,7 +1150,7 @@ function resolveOptions({ entry, cwd = process.cwd(), dtsInput = false, emitDtsO
1132
1150
  if (oxc && vue) throw new Error("[rolldown-plugin-dts] The `oxc` option is not compatible with the `vue` option. Please disable one of them.");
1133
1151
  if (oxc && tsMacro) throw new Error("[rolldown-plugin-dts] The `oxc` option is not compatible with the `tsMacro` option. Please disable one of them.");
1134
1152
  if (tsgo && !warnedTsgo) {
1135
- console.warn("The `tsgo` option is experimental and may change in the future.");
1153
+ console.warn("TypeScript 7.0 does not yet have a stable API and is experimental. Some options will be unavailable.");
1136
1154
  warnedTsgo = true;
1137
1155
  }
1138
1156
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
3
  "type": "module",
4
- "version": "0.27.0",
4
+ "version": "0.27.2",
5
5
  "description": "A Rolldown plugin to generate and bundle dts files.",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -44,7 +44,7 @@
44
44
  "@ts-macro/tsc": "^0.3.6",
45
45
  "@typescript/native-preview": ">=7.0.0-dev.20260325.1",
46
46
  "rolldown": "^1.0.0",
47
- "typescript": "^5.0.0 || ^6.0.0",
47
+ "typescript": "^5.0.0 || ^6.0.0 || ^7.0.0",
48
48
  "vue-tsc": "~3.2.0 || ~3.3.0"
49
49
  },
50
50
  "peerDependenciesMeta": {
@@ -65,9 +65,9 @@
65
65
  "dts-resolver": "^3.0.0",
66
66
  "get-tsconfig": "5.0.0-beta.5",
67
67
  "obug": "^2.1.3",
68
- "yuku-ast": "^0.1.5",
69
- "yuku-codegen": "^0.5.43",
70
- "yuku-parser": "^0.5.43"
68
+ "yuku-ast": "^0.1.7",
69
+ "yuku-codegen": "^0.5.44",
70
+ "yuku-parser": "^0.5.44"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@jridgewell/source-map": "^0.3.11",
@@ -75,7 +75,7 @@
75
75
  "@sxzz/prettier-config": "^2.3.1",
76
76
  "@sxzz/test-utils": "^0.5.18",
77
77
  "@types/node": "^26.1.0",
78
- "@typescript/native-preview": "7.0.0-dev.20260705.1",
78
+ "@typescript/native-preview": "7.0.0-dev.20260706.1",
79
79
  "@volar/typescript": "^2.4.28",
80
80
  "@vue/language-core": "^3.3.6",
81
81
  "arktype": "^2.2.2",
@@ -89,7 +89,7 @@
89
89
  "tsdown": "^0.22.3",
90
90
  "tsnapi": "^1.0.0",
91
91
  "typescript": "^6.0.3",
92
- "vitest": "^4.1.9",
92
+ "vitest": "^4.1.10",
93
93
  "vue": "^3.5.39",
94
94
  "vue-tsc": "^3.3.6",
95
95
  "zod": "^4.4.3"