rolldown-plugin-dts 0.13.14 → 0.14.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
@@ -35,7 +35,6 @@ You can find an example in [here](./rolldown.config.ts).
35
35
  ## Options
36
36
 
37
37
  Configuration options for the plugin.
38
- Certainly! Here’s your documentation with simplified section titles (just the option name, no type annotation):
39
38
 
40
39
  ---
41
40
 
@@ -148,6 +147,17 @@ This is especially useful when you have a single `tsconfig.json` for multiple pr
148
147
 
149
148
  ---
150
149
 
150
+ ### newContext
151
+
152
+ If `true`, the plugin will create a new isolated context for each build,
153
+ ensuring that previously generated `.d.ts` code and caches are not reused.
154
+
155
+ By default, the plugin may reuse internal caches or incremental build artifacts
156
+ to speed up repeated builds. Enabling this option forces a clean context,
157
+ guaranteeing that all type definitions are generated from scratch.
158
+
159
+ ---
160
+
151
161
  ### tsgo
152
162
 
153
163
  **[Experimental]** Enables DTS generation using [`tsgo`](https://github.com/microsoft/typescript-go).
@@ -0,0 +1,28 @@
1
+ import { TsConfigJson } from "get-tsconfig";
2
+ import ts from "typescript";
3
+ import { SourceMapInput } from "rolldown";
4
+
5
+ //#region src/tsc/index.d.ts
6
+ interface TscContext {
7
+ programs: ts.Program[];
8
+ files: Map<string, string>;
9
+ }
10
+ interface TscOptions {
11
+ tsconfig?: string;
12
+ tsconfigRaw: TsConfigJson;
13
+ cwd: string;
14
+ incremental: boolean;
15
+ entries?: string[];
16
+ id: string;
17
+ vue?: boolean;
18
+ context?: TscContext;
19
+ }
20
+ declare function createContext(): TscContext;
21
+ interface TscResult {
22
+ code?: string;
23
+ map?: SourceMapInput;
24
+ error?: string;
25
+ }
26
+ declare function tscEmit(tscOptions: TscOptions): TscResult;
27
+ //#endregion
28
+ export { TscContext, createContext, tscEmit };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE } from "./filename-TbnZq0n4.js";
2
+ import { TscContext, createContext } from "./index-B4kTNEjT.js";
2
3
  import { IsolatedDeclarationsOptions } from "rolldown/experimental";
3
4
  import { TsConfigJson } from "get-tsconfig";
4
5
  import { Plugin } from "rolldown";
@@ -111,6 +112,17 @@ interface Options {
111
112
  * `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
112
113
  */
113
114
  tsgo?: boolean;
115
+ /**
116
+ * If `true`, the plugin will create a new isolated context for each build,
117
+ * ensuring that previously generated `.d.ts` code and caches are not reused.
118
+ *
119
+ * By default, the plugin may reuse internal caches or incremental build artifacts
120
+ * to speed up repeated builds. Enabling this option forces a clean context,
121
+ * guaranteeing that all type definitions are generated from scratch.
122
+ *
123
+ * **Default:** `false`
124
+ */
125
+ newContext?: boolean;
114
126
  }
115
127
  type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
116
128
  type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
@@ -132,7 +144,8 @@ declare function resolveOptions({
132
144
  vue,
133
145
  parallel,
134
146
  eager,
135
- tsgo
147
+ tsgo,
148
+ newContext
136
149
  }: Options): OptionsResolved;
137
150
  //#endregion
138
151
  //#region src/fake-js.d.ts
@@ -152,10 +165,11 @@ declare function createGeneratePlugin({
152
165
  vue,
153
166
  parallel,
154
167
  eager,
155
- tsgo
156
- }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "incremental" | "isolatedDeclarations" | "emitDtsOnly" | "vue" | "parallel" | "eager" | "tsgo">): Plugin;
168
+ tsgo,
169
+ newContext
170
+ }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "incremental" | "isolatedDeclarations" | "emitDtsOnly" | "vue" | "parallel" | "eager" | "tsgo" | "newContext">): Plugin;
157
171
  //#endregion
158
172
  //#region src/index.d.ts
159
173
  declare function dts(options?: Options): Plugin[];
160
174
  //#endregion
161
- export { type Options, RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, createFakeJsPlugin, createGeneratePlugin, dts, resolveOptions };
175
+ export { type Options, RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, type TscContext, createContext, createFakeJsPlugin, createGeneratePlugin, dts, resolveOptions };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_ts_to_dts } from "./filename-Dpr2dKWZ.js";
2
+ import { createContext } from "./tsc-Czx4mPt7.js";
2
3
  import path from "node:path";
3
4
  import Debug from "debug";
4
5
  import _generate from "@babel/generator";
@@ -639,7 +640,7 @@ const spawnAsync = (...args) => new Promise((resolve, reject) => {
639
640
  child.on("close", () => resolve());
640
641
  child.on("error", (error) => reject(error));
641
642
  });
642
- function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, isolatedDeclarations, emitDtsOnly, vue, parallel, eager, tsgo }) {
643
+ function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, isolatedDeclarations, emitDtsOnly, vue, parallel, eager, tsgo, newContext }) {
643
644
  const dtsMap = /* @__PURE__ */ new Map();
644
645
  /**
645
646
  * A map of input id to output file name
@@ -668,8 +669,8 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, isolate
668
669
  async buildStart(options) {
669
670
  if (tsgo) tsgoDist = await runTsgo(cwd, tsconfig);
670
671
  else if (!parallel && (!isolatedDeclarations || vue)) {
671
- tscModule = await import("./tsc-qM2loyiG.js");
672
- tscContext = eager ? void 0 : tscModule.createContext();
672
+ tscModule = await import("./tsc-HJvJZNLs.js");
673
+ if (newContext) tscContext = tscModule.createContext();
673
674
  }
674
675
  if (!Array.isArray(options.input)) for (const [name, id] of Object.entries(options.input)) {
675
676
  debug$1("resolving input alias %s -> %s", name, id);
@@ -792,7 +793,8 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, isolate
792
793
  recursive: true,
793
794
  force: true
794
795
  }).catch(() => {});
795
- tscContext = tsgoDist = void 0;
796
+ tsgoDist = void 0;
797
+ if (newContext) tscContext = void 0;
796
798
  }
797
799
  };
798
800
  }
@@ -820,7 +822,7 @@ async function runTsgo(root, tsconfig) {
820
822
  //#endregion
821
823
  //#region src/options.ts
822
824
  let warnedTsgo = false;
823
- function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, compilerOptions = {}, tsconfigRaw: overriddenTsconfigRaw = {}, isolatedDeclarations, sourcemap, dtsInput = false, emitDtsOnly = false, resolve = false, vue = false, parallel = false, eager = false, tsgo = false }) {
825
+ function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, compilerOptions = {}, tsconfigRaw: overriddenTsconfigRaw = {}, isolatedDeclarations, sourcemap, dtsInput = false, emitDtsOnly = false, resolve = false, vue = false, parallel = false, eager = false, tsgo = false, newContext = false }) {
824
826
  let resolvedTsconfig;
825
827
  if (tsconfig === true || tsconfig == null) {
826
828
  const { config, path: path$1 } = getTsconfig(cwd) || {};
@@ -865,7 +867,8 @@ function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, co
865
867
  vue,
866
868
  parallel,
867
869
  eager,
868
- tsgo
870
+ tsgo,
871
+ newContext
869
872
  };
870
873
  }
871
874
 
@@ -931,4 +934,4 @@ function dts(options = {}) {
931
934
  }
932
935
 
933
936
  //#endregion
934
- export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, createFakeJsPlugin, createGeneratePlugin, dts, resolveOptions };
937
+ export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, createContext, createFakeJsPlugin, createGeneratePlugin, dts, resolveOptions };
@@ -1,29 +1,5 @@
1
- import { TsConfigJson } from "get-tsconfig";
2
- import ts from "typescript";
3
- import { SourceMapInput } from "rolldown";
1
+ import { tscEmit } from "../index-B4kTNEjT.js";
4
2
 
5
- //#region src/tsc/index.d.ts
6
- interface TscContext {
7
- programs: ts.Program[];
8
- files: Map<string, string>;
9
- }
10
- interface TscOptions {
11
- tsconfig?: string;
12
- tsconfigRaw: TsConfigJson;
13
- cwd: string;
14
- incremental: boolean;
15
- entries?: string[];
16
- id: string;
17
- vue?: boolean;
18
- context?: TscContext;
19
- }
20
- interface TscResult {
21
- code?: string;
22
- map?: SourceMapInput;
23
- error?: string;
24
- }
25
- declare function tscEmit(tscOptions: TscOptions): TscResult;
26
- //#endregion
27
3
  //#region src/tsc/worker.d.ts
28
4
  declare const functions: {
29
5
  tscEmit: typeof tscEmit;
@@ -1,4 +1,4 @@
1
- import { tscEmit } from "../tsc-DkRb5DrU.js";
1
+ import { tscEmit } from "../tsc-Czx4mPt7.js";
2
2
  import { createBirpc } from "birpc";
3
3
  import process from "node:process";
4
4
 
@@ -79,9 +79,10 @@ function createVueProgramFactory(ts$1) {
79
79
  return createVueProgram = proxyCreateProgram(ts$1, ts$1.createProgram, (ts$2, options) => {
80
80
  const $rootDir = options.options.$rootDir;
81
81
  const $configRaw = options.options.$configRaw;
82
- const resolver = new vue.CompilerOptionsResolver();
82
+ const resolver = new vue.CompilerOptionsResolver(ts$2.sys.fileExists);
83
83
  resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
84
84
  const vueOptions = resolver.build();
85
+ vue.writeGlobalTypes(vueOptions, ts$2.sys.writeFile);
85
86
  const vueLanguagePlugin = vue.createVueLanguagePlugin(ts$2, options.options, vueOptions, (id) => id);
86
87
  return { languagePlugins: [vueLanguagePlugin] };
87
88
  });
@@ -0,0 +1,3 @@
1
+ import { createContext, tscEmit } from "./tsc-Czx4mPt7.js";
2
+
3
+ export { createContext, tscEmit };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.13.14",
3
+ "version": "0.14.1",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "@typescript/native-preview": ">=7.0.0-dev.20250601.1",
33
33
  "rolldown": "^1.0.0-beta.9",
34
34
  "typescript": "^5.0.0",
35
- "vue-tsc": "^2.2.0 || ^3.0.0"
35
+ "vue-tsc": "~3.0.3"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@typescript/native-preview": {
@@ -58,19 +58,19 @@
58
58
  "devDependencies": {
59
59
  "@sxzz/eslint-config": "^7.0.6",
60
60
  "@sxzz/prettier-config": "^2.2.3",
61
- "@sxzz/test-utils": "^0.5.6",
61
+ "@sxzz/test-utils": "^0.5.7",
62
62
  "@types/babel__generator": "^7.27.0",
63
63
  "@types/debug": "^4.1.12",
64
64
  "@types/node": "^24.0.14",
65
- "@typescript/native-preview": "7.0.0-dev.20250715.1",
66
- "@volar/typescript": "^2.4.19",
67
- "@vue/language-core": "^3.0.1",
65
+ "@typescript/native-preview": "7.0.0-dev.20250718.1",
66
+ "@volar/typescript": "^2.4.20",
67
+ "@vue/language-core": "^3.0.3",
68
68
  "bumpp": "^10.2.0",
69
69
  "diff": "^8.0.2",
70
70
  "eslint": "^9.31.0",
71
71
  "estree-walker": "^3.0.3",
72
72
  "prettier": "^3.6.2",
73
- "rolldown": "^1.0.0-beta.27",
73
+ "rolldown": "^1.0.0-beta.28",
74
74
  "rollup-plugin-dts": "^6.2.1",
75
75
  "tinyglobby": "^0.2.14",
76
76
  "tsdown": "^0.12.9",
@@ -78,7 +78,7 @@
78
78
  "typescript": "^5.8.3",
79
79
  "vitest": "^3.2.4",
80
80
  "vue": "^3.5.17",
81
- "vue-tsc": "^3.0.1"
81
+ "vue-tsc": "^3.0.3"
82
82
  },
83
83
  "engines": {
84
84
  "node": ">=20.18.0"
@@ -1,3 +0,0 @@
1
- import { createContext, tscEmit } from "./tsc-DkRb5DrU.js";
2
-
3
- export { createContext, tscEmit };