rolldown-plugin-dts 0.22.0 → 0.22.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.
@@ -0,0 +1,18 @@
1
+ import ts from "typescript";
2
+
3
+ //#region src/tsc/context.d.ts
4
+ interface ParsedProject {
5
+ tsconfigPath: string;
6
+ parsedConfig: ts.ParsedCommandLine;
7
+ }
8
+ type SourceFileToProjectMap = Map<string, ParsedProject>;
9
+ interface TscContext {
10
+ programs: ts.Program[];
11
+ files: Map<string, string>;
12
+ projects: Map<string, SourceFileToProjectMap>;
13
+ }
14
+ declare function createContext(): TscContext;
15
+ declare function invalidateContextFile(context: TscContext, file: string): void;
16
+ declare const globalContext: TscContext;
17
+ //#endregion
18
+ export { globalContext as a, createContext as i, SourceFileToProjectMap as n, invalidateContextFile as o, TscContext as r, ParsedProject as t };
@@ -1,4 +1,4 @@
1
- import { TscContext } from "./tsc-context.mjs";
1
+ import { r as TscContext } from "./context-BbNuMjMl.mjs";
2
2
  import { SourceMapInput } from "rolldown";
3
3
  import { TsConfigJson } from "get-tsconfig";
4
4
  import ts from "typescript";
@@ -27,4 +27,7 @@ interface TscResult {
27
27
  error?: string;
28
28
  }
29
29
  //#endregion
30
- export { TscOptions as n, TscResult as r, TscModule as t };
30
+ //#region src/tsc/index.d.ts
31
+ declare function tscEmit(tscOptions: TscOptions): TscResult;
32
+ //#endregion
33
+ export { TscResult as i, TscModule as n, TscOptions as r, tscEmit as t };
package/dist/index.mjs CHANGED
@@ -269,6 +269,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
269
269
  start: transformedDep.start,
270
270
  end: transformedDep.end
271
271
  };
272
+ else if (isInfer(transformedDep)) transformedDep.name = "__Infer";
272
273
  if (originalDep.replace) originalDep.replace(transformedDep);
273
274
  else Object.assign(originalDep, transformedDep);
274
275
  }
@@ -470,6 +471,9 @@ function runtimeBindingArrayExpression(elements) {
470
471
  function isThisExpression(node) {
471
472
  return isIdentifierOf(node, "this") || node.type === "ThisExpression" || node.type === "MemberExpression" && isThisExpression(node.object);
472
473
  }
474
+ function isInfer(node) {
475
+ return isIdentifierOf(node, "infer");
476
+ }
473
477
  function TSEntityNameToRuntime(node) {
474
478
  if (node.type === "Identifier" || node.type === "ThisExpression") return node;
475
479
  const left = TSEntityNameToRuntime(node.left);
@@ -490,6 +494,9 @@ function isHelperImport(node) {
490
494
  */
491
495
  function patchImportExport(node, typeOnlyIds, cjsDefault) {
492
496
  if (node.type === "ExportNamedDeclaration" && !node.declaration && !node.source && !node.specifiers.length && !node.attributes?.length) return false;
497
+ if (node.type === "ImportDeclaration" && node.specifiers.length) {
498
+ for (const specifier of node.specifiers) if (isInfer(specifier.local)) specifier.local.name = "__Infer";
499
+ }
493
500
  if (isTypeOf(node, [
494
501
  "ImportDeclaration",
495
502
  "ExportAllDeclaration",
@@ -519,6 +526,7 @@ function patchTsNamespace(nodes) {
519
526
  const result = handleExport(node);
520
527
  if (!result) continue;
521
528
  const [binding, exports] = result;
529
+ if (!exports.properties.length) continue;
522
530
  nodes[i] = {
523
531
  type: "TSModuleDeclaration",
524
532
  id: binding,
@@ -16,7 +16,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
16
16
 
17
17
  //#endregion
18
18
  //#region src/tsc/system.ts
19
- const debug$3 = createDebug("rolldown-plugin-dts:tsc-system");
19
+ const debug$4 = createDebug("rolldown-plugin-dts:tsc-system");
20
20
  /**
21
21
  * A system that writes files to both memory and disk. It will try read files
22
22
  * from memory firstly and fallback to disk if not found.
@@ -25,7 +25,7 @@ function createFsSystem(files) {
25
25
  return {
26
26
  ...ts.sys,
27
27
  write(message) {
28
- debug$3(message);
28
+ debug$4(message);
29
29
  },
30
30
  resolvePath(path) {
31
31
  if (files.has(path)) return path;
@@ -90,20 +90,20 @@ function setSourceMapRoot(map, originalFilePath, finalFilePath) {
90
90
 
91
91
  //#endregion
92
92
  //#region src/tsc/emit-build.ts
93
- const debug$2 = createDebug("rolldown-plugin-dts:tsc-build");
93
+ const debug$3 = createDebug("rolldown-plugin-dts:tsc-build");
94
94
  function tscEmitBuild(tscOptions) {
95
95
  const { id, tsconfig, incremental, context = globalContext, sourcemap } = tscOptions;
96
- debug$2(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
96
+ debug$3(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
97
97
  if (!tsconfig) return { error: "[rolldown-plugin-dts] build mode requires a tsconfig path" };
98
98
  const fsSystem = (incremental ? createFsSystem : createMemorySystem)(context.files);
99
99
  const resolvedId = fsSystem.resolvePath(id);
100
- if (resolvedId !== id) debug$2(`resolved id from ${id} to ${resolvedId}`);
100
+ if (resolvedId !== id) debug$3(`resolved id from ${id} to ${resolvedId}`);
101
101
  const project = getOrBuildProjects(context, fsSystem, tsconfig, !incremental, sourcemap).get(resolvedId);
102
102
  if (!project) {
103
- debug$2(`unable to locate a project containing ${resolvedId}`);
103
+ debug$3(`unable to locate a project containing ${resolvedId}`);
104
104
  return { error: `Unable to locate ${id} from the given tsconfig file ${tsconfig}` };
105
105
  }
106
- debug$2(`loaded project ${project.tsconfigPath} for ${id}`);
106
+ debug$3(`loaded project ${project.tsconfigPath} for ${id}`);
107
107
  const ignoreCase = !fsSystem.useCaseSensitiveFileNames;
108
108
  const outputFiles = ts.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
109
109
  let code;
@@ -133,20 +133,20 @@ function tscEmitBuild(tscOptions) {
133
133
  map
134
134
  };
135
135
  if (incremental) {
136
- debug$2(`incremental build failed`);
136
+ debug$3(`incremental build failed`);
137
137
  return tscEmitBuild({
138
138
  ...tscOptions,
139
139
  incremental: false
140
140
  });
141
141
  }
142
- debug$2(`unable to build .d.ts file for ${id}`);
142
+ debug$3(`unable to build .d.ts file for ${id}`);
143
143
  if (project.parsedConfig.options.declaration !== true) return { error: `Unable to build .d.ts file for ${id}; Make sure the "declaration" option is set to true in ${project.tsconfigPath}` };
144
144
  return { error: `Unable to build .d.ts file for ${id}; This seems like a bug of rolldown-plugin-dts. Please report this issue to https://github.com/sxzz/rolldown-plugin-dts/issues` };
145
145
  }
146
146
  function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
147
147
  let projectMap = context.projects.get(tsconfig);
148
148
  if (projectMap) {
149
- debug$2(`skip building projects for ${tsconfig}`);
149
+ debug$3(`skip building projects for ${tsconfig}`);
150
150
  return projectMap;
151
151
  }
152
152
  projectMap = buildProjects(fsSystem, tsconfig, force, sourcemap);
@@ -157,15 +157,15 @@ function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
157
157
  * Use TypeScript compiler to build all projects referenced
158
158
  */
159
159
  function buildProjects(fsSystem, tsconfig, force, sourcemap) {
160
- debug$2(`start building projects for ${tsconfig}`);
160
+ debug$3(`start building projects for ${tsconfig}`);
161
161
  const projects = collectProjectGraph(tsconfig, fsSystem, force, sourcemap);
162
- debug$2("collected %d projects: %j", projects.length, projects.map((project) => project.tsconfigPath));
162
+ debug$3("collected %d projects: %j", projects.length, projects.map((project) => project.tsconfigPath));
163
163
  const host = ts.createSolutionBuilderHost(fsSystem, createProgramWithPatchedCompilerOptions);
164
- debug$2(`built solution for ${tsconfig} with exit status ${ts.createSolutionBuilder(host, [tsconfig], {
164
+ debug$3(`built solution for ${tsconfig} with exit status ${ts.createSolutionBuilder(host, [tsconfig], {
165
165
  force,
166
166
  verbose: true
167
167
  }).build(void 0, void 0, void 0, (project) => {
168
- debug$2(`transforming project ${project}`);
168
+ debug$3(`transforming project ${project}`);
169
169
  return customTransformers;
170
170
  })}`);
171
171
  const sourceFileToProjectMap = /* @__PURE__ */ new Map();
@@ -244,9 +244,9 @@ const createProgramWithPatchedCompilerOptions = (rootNames, options, ...args) =>
244
244
 
245
245
  //#endregion
246
246
  //#region src/tsc/volar.ts
247
- const debug$1 = createDebug("rolldown-plugin-dts:volar");
247
+ const debug$2 = createDebug("rolldown-plugin-dts:volar");
248
248
  function loadVueLanguageTools() {
249
- debug$1("loading vue language tools");
249
+ debug$2("loading vue language tools");
250
250
  try {
251
251
  const vueTscPath = __require.resolve("vue-tsc");
252
252
  return {
@@ -254,7 +254,7 @@ function loadVueLanguageTools() {
254
254
  vue: __require(__require.resolve("@vue/language-core", { paths: [vueTscPath] }))
255
255
  };
256
256
  } catch (error) {
257
- debug$1("vue language tools not found", error);
257
+ debug$2("vue language tools not found", error);
258
258
  throw new Error("Failed to load vue language tools. Please manually install vue-tsc.");
259
259
  }
260
260
  }
@@ -309,7 +309,7 @@ function createProgramFactory(ts, options) {
309
309
 
310
310
  //#endregion
311
311
  //#region src/tsc/emit-compiler.ts
312
- const debug = createDebug("rolldown-plugin-dts:tsc-compiler");
312
+ const debug$1 = createDebug("rolldown-plugin-dts:tsc-compiler");
313
313
  const defaultCompilerOptions = {
314
314
  declaration: true,
315
315
  noEmit: false,
@@ -336,9 +336,9 @@ function createOrGetTsModule(options) {
336
336
  file: sourceFile
337
337
  };
338
338
  }
339
- debug(`create program for module: ${id}`);
339
+ debug$1(`create program for module: ${id}`);
340
340
  const module = createTsProgram(options);
341
- debug(`created program for module: ${id}`);
341
+ debug$1(`created program for module: ${id}`);
342
342
  context.programs.push(module.program);
343
343
  return module;
344
344
  }
@@ -350,7 +350,7 @@ function createTsProgram({ entries, id, tsconfig, tsconfigRaw, vue, tsMacro, cwd
350
350
  isMixedContent: true,
351
351
  scriptKind: ts.ScriptKind.Deferred
352
352
  }] : void 0);
353
- debug(`creating program for root project: ${baseDir}`);
353
+ debug$1(`creating program for root project: ${baseDir}`);
354
354
  return createTsProgramFromParsedConfig({
355
355
  parsedConfig,
356
356
  fsSystem,
@@ -381,13 +381,13 @@ function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id,
381
381
  });
382
382
  const sourceFile = program.getSourceFile(id);
383
383
  if (!sourceFile) {
384
- debug(`source file not found in program: ${id}`);
384
+ debug$1(`source file not found in program: ${id}`);
385
385
  if (!!parsedConfig.projectReferences?.length) throw new Error(`[rolldown-plugin-dts] Unable to load ${id}; You have "references" in your tsconfig file. Perhaps you want to add \`dts: { build: true }\` in your config?`);
386
386
  if (fsSystem.fileExists(id)) {
387
- debug(`File ${id} exists on disk.`);
387
+ debug$1(`File ${id} exists on disk.`);
388
388
  throw new Error(`Unable to load file ${id} from the program. This seems like a bug of rolldown-plugin-dts. Please report this issue to https://github.com/sxzz/rolldown-plugin-dts/issues`);
389
389
  } else {
390
- debug(`File ${id} does not exist on disk.`);
390
+ debug$1(`File ${id} does not exist on disk.`);
391
391
  throw new Error(`Source file not found: ${id}`);
392
392
  }
393
393
  }
@@ -397,26 +397,26 @@ function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id,
397
397
  };
398
398
  }
399
399
  function tscEmitCompiler(tscOptions) {
400
- debug(`running tscEmitCompiler ${tscOptions.id}`);
400
+ debug$1(`running tscEmitCompiler ${tscOptions.id}`);
401
401
  const { program, file } = createOrGetTsModule(tscOptions);
402
- debug(`got source file: ${file.fileName}`);
402
+ debug$1(`got source file: ${file.fileName}`);
403
403
  let dtsCode;
404
404
  let map;
405
405
  const { emitSkipped, diagnostics } = program.emit(file, (fileName, code) => {
406
406
  if (fileName.endsWith(".map")) {
407
- debug(`emit dts sourcemap: ${fileName}`);
407
+ debug$1(`emit dts sourcemap: ${fileName}`);
408
408
  map = JSON.parse(code);
409
409
  setSourceMapRoot(map, fileName, tscOptions.id);
410
410
  } else {
411
- debug(`emit dts: ${fileName}`);
411
+ debug$1(`emit dts: ${fileName}`);
412
412
  dtsCode = code;
413
413
  }
414
414
  }, void 0, true, customTransformers, true);
415
415
  if (emitSkipped && diagnostics.length) return { error: ts.formatDiagnostics(diagnostics, formatHost) };
416
416
  if (!dtsCode) {
417
- debug("nothing was emitted.");
417
+ debug$1("nothing was emitted.");
418
418
  if (file.isDeclarationFile) {
419
- debug("source file is a declaration file.");
419
+ debug$1("source file is a declaration file.");
420
420
  dtsCode = file.getFullText();
421
421
  } else console.warn("[rolldown-plugin-dts] Warning: Failed to emit declaration file. Please try to enable `eager` option (`dts.eager` for tsdown).");
422
422
  }
@@ -427,4 +427,14 @@ function tscEmitCompiler(tscOptions) {
427
427
  }
428
428
 
429
429
  //#endregion
430
- export { tscEmitBuild as n, tscEmitCompiler as t };
430
+ //#region src/tsc/index.ts
431
+ const debug = createDebug("rolldown-plugin-dts:tsc");
432
+ debug(`loaded typescript: ${ts.version}`);
433
+ function tscEmit(tscOptions) {
434
+ debug(`running tscEmit ${tscOptions.id}`);
435
+ if (tscOptions.build) return tscEmitBuild(tscOptions);
436
+ else return tscEmitCompiler(tscOptions);
437
+ }
438
+
439
+ //#endregion
440
+ export { tscEmit as t };
@@ -1,18 +1,2 @@
1
- import ts from "typescript";
2
-
3
- //#region src/tsc/context.d.ts
4
- interface ParsedProject {
5
- tsconfigPath: string;
6
- parsedConfig: ts.ParsedCommandLine;
7
- }
8
- type SourceFileToProjectMap = Map<string, ParsedProject>;
9
- interface TscContext {
10
- programs: ts.Program[];
11
- files: Map<string, string>;
12
- projects: Map<string, SourceFileToProjectMap>;
13
- }
14
- declare function createContext(): TscContext;
15
- declare function invalidateContextFile(context: TscContext, file: string): void;
16
- declare const globalContext: TscContext;
17
- //#endregion
1
+ import { a as globalContext, i as createContext, n as SourceFileToProjectMap, o as invalidateContextFile, r as TscContext, t as ParsedProject } from "./context-BbNuMjMl.mjs";
18
2
  export { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile };
@@ -1,4 +1,4 @@
1
- import { tscEmit } from "./tsc.mjs";
1
+ import { t as tscEmit } from "./index-CJd0fw6p.mjs";
2
2
 
3
3
  //#region src/tsc/worker.d.ts
4
4
  declare const functions: {
@@ -1,4 +1,4 @@
1
- import { tscEmit } from "./tsc.mjs";
1
+ import { t as tscEmit } from "./tsc-GyRYMxqk.mjs";
2
2
  const process = globalThis.process;
3
3
  import { createBirpc } from "birpc";
4
4
 
package/dist/tsc.d.mts CHANGED
@@ -1,6 +1,2 @@
1
- import { n as TscOptions, r as TscResult, t as TscModule } from "./types-D8g6CB60.mjs";
2
-
3
- //#region src/tsc/index.d.ts
4
- declare function tscEmit(tscOptions: TscOptions): TscResult;
5
- //#endregion
6
- export { type TscModule, type TscOptions, type TscResult, tscEmit };
1
+ import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-CJd0fw6p.mjs";
2
+ export { TscModule, TscOptions, TscResult, tscEmit };
package/dist/tsc.mjs CHANGED
@@ -1,16 +1,3 @@
1
- const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
2
- import { n as tscEmitBuild, t as tscEmitCompiler } from "./emit-compiler-CfQ29zff.mjs";
3
- import { createDebug } from "obug";
4
- const ts = __cjs_require("typescript");
1
+ import { t as tscEmit } from "./tsc-GyRYMxqk.mjs";
5
2
 
6
- //#region src/tsc/index.ts
7
- const debug = createDebug("rolldown-plugin-dts:tsc");
8
- debug(`loaded typescript: ${ts.version}`);
9
- function tscEmit(tscOptions) {
10
- debug(`running tscEmit ${tscOptions.id}`);
11
- if (tscOptions.build) return tscEmitBuild(tscOptions);
12
- else return tscEmitCompiler(tscOptions);
13
- }
14
-
15
- //#endregion
16
3
  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.0",
4
+ "version": "0.22.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.20250601.1",
46
46
  "rolldown": "^1.0.0-rc.3",
47
- "typescript": "^5.0.0",
47
+ "typescript": "^5.0.0 || ^6.0.0-beta",
48
48
  "vue-tsc": "~3.2.0"
49
49
  },
50
50
  "peerDependenciesMeta": {
@@ -69,36 +69,37 @@
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.1",
72
+ "get-tsconfig": "^4.13.6",
73
73
  "obug": "^2.1.1"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@jridgewell/source-map": "^0.3.11",
77
- "@sxzz/eslint-config": "^7.6.0",
77
+ "@sxzz/eslint-config": "^7.8.1",
78
78
  "@sxzz/prettier-config": "^2.3.1",
79
79
  "@sxzz/test-utils": "^0.5.15",
80
- "@types/node": "^25.2.0",
81
- "@typescript/native-preview": "7.0.0-dev.20260204.1",
80
+ "@types/node": "^25.3.1",
81
+ "@typescript/native-preview": "7.0.0-dev.20260226.1",
82
82
  "@volar/typescript": "^2.4.28",
83
- "@vue/language-core": "^3.2.4",
83
+ "@vue/language-core": "^3.2.5",
84
84
  "arktype": "^2.1.29",
85
- "bumpp": "^10.4.0",
85
+ "bumpp": "^10.4.1",
86
86
  "diff": "^8.0.3",
87
- "eslint": "^9.39.2",
87
+ "eslint": "^10.0.2",
88
88
  "prettier": "^3.8.1",
89
- "rolldown": "^1.0.0-rc.3",
89
+ "rolldown": "^1.0.0-rc.5",
90
90
  "rolldown-plugin-dts-snapshot": "^0.3.2",
91
91
  "rolldown-plugin-require-cjs": "^0.3.3",
92
92
  "rollup-plugin-dts": "^6.3.0",
93
93
  "tinyglobby": "^0.2.15",
94
- "tsdown": "^0.20.1",
95
- "typescript": "^5.9.3",
94
+ "tsdown": "^0.21.0-beta.1",
95
+ "typescript": "6.0.0-beta",
96
96
  "vitest": "^4.0.18",
97
- "vue": "^3.5.27",
98
- "vue-tsc": "^3.2.4"
97
+ "vue": "^3.5.29",
98
+ "vue-tsc": "^3.2.5",
99
+ "zod": "^4.3.6"
99
100
  },
100
101
  "resolutions": {
101
- "rolldown": "^1.0.0-rc.3"
102
+ "rolldown": "^1.0.0-rc.5"
102
103
  },
103
104
  "prettier": "@sxzz/prettier-config",
104
105
  "scripts": {