rolldown-plugin-dts 0.16.3 → 0.16.5

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
@@ -99,6 +99,14 @@ If set to `true`, and you are only exporting a single item using `export default
99
99
  the output will use `export = ...` instead of the standard ES module syntax.
100
100
  This is useful for compatibility with CommonJS.
101
101
 
102
+ #### `banner`
103
+
104
+ Content to be added at the top of each generated `.d.ts` file.
105
+
106
+ #### `footer`
107
+
108
+ Content to be added at the bottom of each generated `.d.ts` file.
109
+
102
110
  ### `tsc` Options
103
111
 
104
112
  > [!NOTE]
@@ -18,6 +18,7 @@ interface TscOptions {
18
18
  id: string;
19
19
  sourcemap: boolean;
20
20
  vue?: boolean;
21
+ tsMacro?: boolean;
21
22
  context?: TscContext;
22
23
  }
23
24
  interface TscResult {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE } from "./filename-BDKLOOY5.js";
2
2
  import { IsolatedDeclarationsOptions } from "rolldown/experimental";
3
3
  import { TsConfigJson } from "get-tsconfig";
4
- import { Plugin } from "rolldown";
4
+ import { AddonFunction, Plugin } from "rolldown";
5
5
 
6
6
  //#region src/options.d.ts
7
7
  interface GeneralOptions {
@@ -110,6 +110,10 @@ interface TscOptions {
110
110
  */
111
111
  vue?: boolean;
112
112
  /**
113
+ * If `true`, the plugin will generate `.d.ts` files using `@ts-macro/tsc`.
114
+ */
115
+ tsMacro?: boolean;
116
+ /**
113
117
  * If `true`, the plugin will launch a separate process for `tsc` or `vue-tsc`.
114
118
  * This enables processing multiple projects in parallel.
115
119
  */
@@ -140,6 +144,14 @@ interface TscOptions {
140
144
  * `false`.
141
145
  */
142
146
  emitJs?: boolean;
147
+ /**
148
+ * Content to be added at the top of each generated `.d.ts` file.
149
+ */
150
+ banner?: string | Promise<string> | AddonFunction;
151
+ /**
152
+ * Content to be added at the bottom of each generated `.d.ts` file.
153
+ */
154
+ footer?: string | Promise<string> | AddonFunction;
143
155
  }
144
156
  interface Options extends GeneralOptions, TscOptions {
145
157
  /**
@@ -160,8 +172,9 @@ interface Options extends GeneralOptions, TscOptions {
160
172
  tsgo?: boolean;
161
173
  }
162
174
  type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
163
- type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
164
- tsconfig: string | undefined;
175
+ type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
176
+ type OptionsResolved = Overwrite<MarkPartial<Omit<Options, "compilerOptions">, "banner" | "footer">, {
177
+ tsconfig?: string;
165
178
  oxc: IsolatedDeclarationsOptions | false;
166
179
  tsconfigRaw: TsConfigJson;
167
180
  }>;
@@ -175,9 +188,12 @@ declare function resolveOptions({
175
188
  sourcemap,
176
189
  resolve,
177
190
  cjsDefault,
191
+ banner,
192
+ footer,
178
193
  build,
179
194
  incremental,
180
195
  vue,
196
+ tsMacro,
181
197
  parallel,
182
198
  eager,
183
199
  newContext,
@@ -202,13 +218,14 @@ declare function createGeneratePlugin({
202
218
  oxc,
203
219
  emitDtsOnly,
204
220
  vue,
221
+ tsMacro,
205
222
  parallel,
206
223
  eager,
207
224
  tsgo,
208
225
  newContext,
209
226
  emitJs,
210
227
  sourcemap
211
- }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "build" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs" | "sourcemap">): Plugin;
228
+ }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "build" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "tsMacro" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs" | "sourcemap">): Plugin;
212
229
  //#endregion
213
230
  //#region src/index.d.ts
214
231
  declare function dts(options?: Options): Plugin[];
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
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_to_dts, replaceTemplateName, resolveTemplateFn } from "./filename-Dd76wOJT.js";
2
2
  import { createContext, globalContext, invalidateContextFile } from "./context-Digr9tkU.js";
3
3
  import Debug from "debug";
4
+ import MagicString from "magic-string";
4
5
  import _generate from "@babel/generator";
5
6
  import { parse } from "@babel/parser";
6
7
  import * as t from "@babel/types";
@@ -15,6 +16,36 @@ import process from "node:process";
15
16
  import { getTsconfig, parseTsconfig } from "get-tsconfig";
16
17
  import { createResolver } from "dts-resolver";
17
18
 
19
+ //#region src/banner.ts
20
+ function createBannerPlugin({ banner, footer }) {
21
+ return {
22
+ name: "rolldown-plugin-dts:banner",
23
+ async renderChunk(code, chunk) {
24
+ if (!RE_DTS.test(chunk.fileName)) return;
25
+ const s = new MagicString(code);
26
+ if (banner) {
27
+ const code$1 = await (typeof banner === "function" ? banner(chunk) : banner);
28
+ if (code$1) s.prepend(`${code$1}\n`);
29
+ }
30
+ if (footer) {
31
+ const code$1 = await (typeof footer === "function" ? footer(chunk) : footer);
32
+ if (code$1) s.append(`\n${code$1}`);
33
+ }
34
+ return {
35
+ code: s.toString(),
36
+ get map() {
37
+ return s.generateMap({
38
+ source: chunk.fileName,
39
+ includeContent: true,
40
+ hires: "boundary"
41
+ });
42
+ }
43
+ };
44
+ }
45
+ };
46
+ }
47
+
48
+ //#endregion
18
49
  //#region src/dts-input.ts
19
50
  function createDtsInputPlugin() {
20
51
  return {
@@ -325,11 +356,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault }) {
325
356
  ...sideEffect ? [t.callExpression(t.identifier("sideEffect"), [bindings[0]])] : []
326
357
  ];
327
358
  const runtime = t.arrayExpression(elements);
328
- if (decl !== stmt) {
329
- decl.innerComments = stmt.innerComments;
330
- decl.leadingComments = stmt.leadingComments;
331
- decl.trailingComments = stmt.trailingComments;
332
- }
359
+ if (decl !== stmt) decl.leadingComments = stmt.leadingComments;
333
360
  const symbolId = registerSymbol({
334
361
  decl,
335
362
  deps,
@@ -662,7 +689,6 @@ function inheritNodeComments(oldNode, newNode) {
662
689
  const leadingComments = oldNode.leadingComments?.filter((comment) => comment.value.startsWith("#"));
663
690
  if (leadingComments) newNode.leadingComments.unshift(...leadingComments);
664
691
  newNode.leadingComments = collectReferenceDirectives(newNode.leadingComments, true);
665
- newNode.trailingComments = newNode.trailingComments?.filter((comment) => !comment.value.startsWith("# sourceMappingURL"));
666
692
  return newNode;
667
693
  }
668
694
 
@@ -675,7 +701,7 @@ const spawnAsync = (...args) => new Promise((resolve, reject) => {
675
701
  child.on("close", () => resolve());
676
702
  child.on("error", (error) => reject(error));
677
703
  });
678
- function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd, oxc, emitDtsOnly, vue, parallel, eager, tsgo, newContext, emitJs, sourcemap }) {
704
+ function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd, oxc, emitDtsOnly, vue, tsMacro, parallel, eager, tsgo, newContext, emitJs, sourcemap }) {
679
705
  const dtsMap = /* @__PURE__ */ new Map();
680
706
  /**
681
707
  * A map of input id to output file name
@@ -812,6 +838,7 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd,
812
838
  id,
813
839
  sourcemap,
814
840
  vue,
841
+ tsMacro,
815
842
  context: tscContext
816
843
  };
817
844
  let result;
@@ -869,7 +896,7 @@ async function runTsgo(root, tsconfig) {
869
896
  //#endregion
870
897
  //#region src/options.ts
871
898
  let warnedTsgo = false;
872
- function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap, resolve = false, cjsDefault = false, build = false, incremental = false, vue = false, parallel = false, eager = false, newContext = false, emitJs, oxc, tsgo = false }) {
899
+ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap, resolve = false, cjsDefault = false, banner, footer, build = false, incremental = false, vue = false, tsMacro = false, parallel = false, eager = false, newContext = false, emitJs, oxc, tsgo = false }) {
873
900
  let resolvedTsconfig;
874
901
  if (tsconfig === true || tsconfig == null) {
875
902
  const { config, path: path$1 } = getTsconfig(cwd) || {};
@@ -891,7 +918,7 @@ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = f
891
918
  ...overriddenTsconfigRaw,
892
919
  compilerOptions
893
920
  };
894
- oxc ??= !!(compilerOptions?.isolatedDeclarations && !vue && !tsgo);
921
+ oxc ??= !!(compilerOptions?.isolatedDeclarations && !vue && !tsgo && !tsMacro);
895
922
  if (oxc === true) oxc = {};
896
923
  if (oxc) {
897
924
  oxc.stripInternal ??= !!compilerOptions?.stripInternal;
@@ -900,9 +927,11 @@ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = f
900
927
  emitJs ??= !!(compilerOptions.checkJs || compilerOptions.allowJs);
901
928
  if (tsgo) {
902
929
  if (vue) throw new Error("[rolldown-plugin-dts] The `tsgo` option is not compatible with the `vue` option. Please disable one of them.");
930
+ if (tsMacro) throw new Error("[rolldown-plugin-dts] The `tsgo` option is not compatible with the `tsMacro` option. Please disable one of them.");
903
931
  if (oxc) throw new Error("[rolldown-plugin-dts] The `tsgo` option is not compatible with the `oxc` option. Please disable one of them.");
904
932
  }
905
933
  if (oxc && vue) throw new Error("[rolldown-plugin-dts] The `oxc` option is not compatible with the `vue` option. Please disable one of them.");
934
+ if (oxc && tsMacro) throw new Error("[rolldown-plugin-dts] The `oxc` option is not compatible with the `tsMacro` option. Please disable one of them.");
906
935
  if (tsgo && !warnedTsgo) {
907
936
  console.warn("The `tsgo` option is experimental and may change in the future.");
908
937
  warnedTsgo = true;
@@ -916,9 +945,12 @@ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = f
916
945
  sourcemap,
917
946
  resolve,
918
947
  cjsDefault,
948
+ banner,
949
+ footer,
919
950
  build,
920
951
  incremental,
921
952
  vue,
953
+ tsMacro,
922
954
  parallel,
923
955
  eager,
924
956
  newContext,
@@ -987,6 +1019,7 @@ function dts(options = {}) {
987
1019
  if (options.dtsInput) plugins.push(createDtsInputPlugin());
988
1020
  else plugins.push(createGeneratePlugin(resolved));
989
1021
  plugins.push(createDtsResolvePlugin(resolved), createFakeJsPlugin(resolved));
1022
+ if (options.banner || options.footer) plugins.push(createBannerPlugin(resolved));
990
1023
  return plugins;
991
1024
  }
992
1025
 
@@ -6,7 +6,7 @@ import ts from "typescript";
6
6
  import { pathToFileURL } from "node:url";
7
7
 
8
8
  //#region src/tsc/system.ts
9
- const debug$4 = Debug("rolldown-plugin-dts:tsc-system");
9
+ const debug$3 = Debug("rolldown-plugin-dts:tsc-system");
10
10
  /**
11
11
  * A system that writes files to both memory and disk. It will try read files
12
12
  * from memory firstly and fallback to disk if not found.
@@ -15,7 +15,7 @@ function createFsSystem(files) {
15
15
  return {
16
16
  ...ts.sys,
17
17
  write(message) {
18
- debug$4(message);
18
+ debug$3(message);
19
19
  },
20
20
  resolvePath(path$1) {
21
21
  if (files.has(path$1)) return path$1;
@@ -80,20 +80,20 @@ function setSourceMapRoot(map, originalFilePath, finalFilePath) {
80
80
 
81
81
  //#endregion
82
82
  //#region src/tsc/emit-build.ts
83
- const debug$3 = Debug("rolldown-plugin-dts:tsc-build");
83
+ const debug$2 = Debug("rolldown-plugin-dts:tsc-build");
84
84
  function tscEmitBuild(tscOptions) {
85
85
  const { id, tsconfig, incremental, context = globalContext, sourcemap } = tscOptions;
86
- debug$3(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
86
+ debug$2(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
87
87
  if (!tsconfig) return { error: "[rolldown-plugin-dts] build mode requires a tsconfig path" };
88
88
  const fsSystem = (incremental ? createFsSystem : createMemorySystem)(context.files);
89
89
  const resolvedId = fsSystem.resolvePath(id);
90
- if (resolvedId !== id) debug$3(`resolved id from ${id} to ${resolvedId}`);
90
+ if (resolvedId !== id) debug$2(`resolved id from ${id} to ${resolvedId}`);
91
91
  const project = getOrBuildProjects(context, fsSystem, tsconfig, !incremental, sourcemap).get(resolvedId);
92
92
  if (!project) {
93
- debug$3(`unable to locate a project containing ${resolvedId}`);
93
+ debug$2(`unable to locate a project containing ${resolvedId}`);
94
94
  return { error: `Unable to locate ${id} from the given tsconfig file ${tsconfig}` };
95
95
  }
96
- debug$3(`loaded project ${project.tsconfigPath} for ${id}`);
96
+ debug$2(`loaded project ${project.tsconfigPath} for ${id}`);
97
97
  const ignoreCase = !fsSystem.useCaseSensitiveFileNames;
98
98
  const outputFiles = ts.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
99
99
  let code;
@@ -123,20 +123,20 @@ function tscEmitBuild(tscOptions) {
123
123
  map
124
124
  };
125
125
  if (incremental) {
126
- debug$3(`incremental build failed`);
126
+ debug$2(`incremental build failed`);
127
127
  return tscEmitBuild({
128
128
  ...tscOptions,
129
129
  incremental: false
130
130
  });
131
131
  }
132
- debug$3(`unable to build .d.ts file for ${id}`);
132
+ debug$2(`unable to build .d.ts file for ${id}`);
133
133
  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}` };
134
134
  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` };
135
135
  }
136
136
  function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
137
137
  let projectMap = context.projects.get(tsconfig);
138
138
  if (projectMap) {
139
- debug$3(`skip building projects for ${tsconfig}`);
139
+ debug$2(`skip building projects for ${tsconfig}`);
140
140
  return projectMap;
141
141
  }
142
142
  projectMap = buildProjects(fsSystem, tsconfig, force, sourcemap);
@@ -147,18 +147,18 @@ function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
147
147
  * Use TypeScript compiler to build all projects referenced
148
148
  */
149
149
  function buildProjects(fsSystem, tsconfig, force, sourcemap) {
150
- debug$3(`start building projects for ${tsconfig}`);
150
+ debug$2(`start building projects for ${tsconfig}`);
151
151
  const projects = collectProjectGraph(tsconfig, fsSystem, force, sourcemap);
152
- debug$3("collected %d projects: %j", projects.length, projects.map((project) => project.tsconfigPath));
152
+ debug$2("collected %d projects: %j", projects.length, projects.map((project) => project.tsconfigPath));
153
153
  const host = ts.createSolutionBuilderHost(fsSystem, createProgramWithPatchedCompilerOptions);
154
154
  const exitStatus = ts.createSolutionBuilder(host, [tsconfig], {
155
155
  force,
156
156
  verbose: true
157
157
  }).build(void 0, void 0, void 0, (project) => {
158
- debug$3(`transforming project ${project}`);
158
+ debug$2(`transforming project ${project}`);
159
159
  return customTransformers;
160
160
  });
161
- debug$3(`built solution for ${tsconfig} with exit status ${exitStatus}`);
161
+ debug$2(`built solution for ${tsconfig} with exit status ${exitStatus}`);
162
162
  const sourceFileToProjectMap = /* @__PURE__ */ new Map();
163
163
  for (const project of projects) for (const fileName of project.parsedConfig.fileNames) sourceFileToProjectMap.set(fsSystem.resolvePath(fileName), project);
164
164
  return sourceFileToProjectMap;
@@ -234,36 +234,64 @@ const createProgramWithPatchedCompilerOptions = (rootNames, options, ...args) =>
234
234
  };
235
235
 
236
236
  //#endregion
237
- //#region src/tsc/vue.ts
238
- const debug$2 = Debug("rolldown-plugin-dts:vue");
239
- let createVueProgram;
237
+ //#region src/tsc/volar.ts
240
238
  const require = createRequire(import.meta.url);
241
239
  function loadVueLanguageTools() {
240
+ const debug$4 = Debug("rolldown-plugin-dts:vue");
241
+ debug$4("loading vue language tools");
242
242
  try {
243
243
  const vueTscPath = require.resolve("vue-tsc");
244
244
  const { proxyCreateProgram } = require(require.resolve("@volar/typescript", { paths: [vueTscPath] }));
245
245
  const vue = require(require.resolve("@vue/language-core", { paths: [vueTscPath] }));
246
+ const getLanguagePlugin = (ts$1, options) => {
247
+ const $rootDir = options.options.$rootDir;
248
+ const $configRaw = options.options.$configRaw;
249
+ const resolver = new vue.CompilerOptionsResolver(ts$1.sys.fileExists);
250
+ resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
251
+ const vueOptions = resolver.build();
252
+ vue.writeGlobalTypes(vueOptions, ts$1.sys.writeFile);
253
+ return vue.createVueLanguagePlugin(ts$1, options.options, vueOptions, (id) => id);
254
+ };
246
255
  return {
247
256
  proxyCreateProgram,
248
- vue
257
+ getLanguagePlugin
249
258
  };
250
259
  } catch (error) {
251
- debug$2("vue language tools not found", error);
260
+ debug$4("vue language tools not found", error);
252
261
  throw new Error("Failed to load vue language tools. Please manually install vue-tsc.");
253
262
  }
254
263
  }
255
- function createVueProgramFactory(ts$1) {
256
- if (createVueProgram) return createVueProgram;
257
- debug$2("loading vue language tools");
258
- const { proxyCreateProgram, vue } = loadVueLanguageTools();
259
- return createVueProgram = proxyCreateProgram(ts$1, ts$1.createProgram, (ts$2, options) => {
260
- const $rootDir = options.options.$rootDir;
261
- const $configRaw = options.options.$configRaw;
262
- const resolver = new vue.CompilerOptionsResolver(ts$2.sys.fileExists);
263
- resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
264
- const vueOptions = resolver.build();
265
- vue.writeGlobalTypes(vueOptions, ts$2.sys.writeFile);
266
- return { languagePlugins: [vue.createVueLanguagePlugin(ts$2, options.options, vueOptions, (id) => id)] };
264
+ function loadTsMacro() {
265
+ const debug$4 = Debug("rolldown-plugin-dts:ts-macro");
266
+ debug$4("loading ts-macro language tools");
267
+ try {
268
+ const tsMacroPath = require.resolve("@ts-macro/tsc");
269
+ const { proxyCreateProgram } = require(require.resolve("@volar/typescript", { paths: [tsMacroPath] }));
270
+ const tsMacro = require(require.resolve("@ts-macro/language-plugin", { paths: [tsMacroPath] }));
271
+ const { getOptions } = require(require.resolve("@ts-macro/language-plugin/options", { paths: [tsMacroPath] }));
272
+ const getLanguagePlugin = (ts$1, options) => {
273
+ const $rootDir = options.options.$rootDir;
274
+ return tsMacro.getLanguagePlugins(ts$1, options.options, getOptions(ts$1, $rootDir))[0];
275
+ };
276
+ return {
277
+ proxyCreateProgram,
278
+ getLanguagePlugin
279
+ };
280
+ } catch (error) {
281
+ debug$4("ts-macro language tools not found", error);
282
+ throw new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.");
283
+ }
284
+ }
285
+ function createProgramFactory(ts$1, options) {
286
+ const vueLanguageTools = options.vue ? loadVueLanguageTools() : void 0;
287
+ const tsMacroLanguageTools = options.tsMacro ? loadTsMacro() : void 0;
288
+ const proxyCreateProgram = vueLanguageTools?.proxyCreateProgram || tsMacroLanguageTools?.proxyCreateProgram;
289
+ if (!proxyCreateProgram) return ts$1.createProgram;
290
+ return proxyCreateProgram(ts$1, ts$1.createProgram, (ts$2, options$1) => {
291
+ const languagePlugins = [];
292
+ if (vueLanguageTools) languagePlugins.push(vueLanguageTools.getLanguagePlugin(ts$2, options$1));
293
+ if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts$2, options$1));
294
+ return { languagePlugins };
267
295
  });
268
296
  }
269
297
 
@@ -302,7 +330,7 @@ function createOrGetTsModule(options) {
302
330
  context.programs.push(module.program);
303
331
  return module;
304
332
  }
305
- function createTsProgram({ entries, id, tsconfig, tsconfigRaw, vue, cwd, context = globalContext }) {
333
+ function createTsProgram({ entries, id, tsconfig, tsconfigRaw, vue, tsMacro, cwd, context = globalContext }) {
306
334
  const fsSystem = createFsSystem(context.files);
307
335
  const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
308
336
  const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir);
@@ -313,10 +341,11 @@ function createTsProgram({ entries, id, tsconfig, tsconfigRaw, vue, cwd, context
313
341
  baseDir,
314
342
  id,
315
343
  entries,
316
- vue
344
+ vue,
345
+ tsMacro
317
346
  });
318
347
  }
319
- function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id, entries, vue }) {
348
+ function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id, entries, vue, tsMacro }) {
320
349
  const compilerOptions = {
321
350
  ...defaultCompilerOptions,
322
351
  ...parsedConfig.options,
@@ -325,7 +354,10 @@ function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id,
325
354
  };
326
355
  const rootNames = [...new Set([id, ...entries || parsedConfig.fileNames].map((f) => fsSystem.resolvePath(f)))];
327
356
  const host = ts.createCompilerHost(compilerOptions, true);
328
- const program = (vue ? createVueProgramFactory(ts) : ts.createProgram)({
357
+ const program = createProgramFactory(ts, {
358
+ vue,
359
+ tsMacro
360
+ })({
329
361
  rootNames,
330
362
  options: compilerOptions,
331
363
  host,
@@ -1,5 +1,5 @@
1
1
  import "./context-DXNtAHtR.js";
2
- import { tscEmit } from "./index-Cbz-60ZO.js";
2
+ import { tscEmit } from "./index-CxJisQQS.js";
3
3
 
4
4
  //#region src/tsc/worker.d.ts
5
5
  declare const functions: {
@@ -1,5 +1,5 @@
1
1
  import "./context-Digr9tkU.js";
2
- import { tscEmit } from "./tsc-q7n7-QbP.js";
2
+ import { tscEmit } from "./tsc-DLbQk3B6.js";
3
3
  import process from "node:process";
4
4
  import { createBirpc } from "birpc";
5
5
 
package/dist/tsc.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./context-DXNtAHtR.js";
2
- import { TscModule, TscOptions, TscResult, tscEmit } from "./index-Cbz-60ZO.js";
2
+ import { TscModule, TscOptions, TscResult, tscEmit } from "./index-CxJisQQS.js";
3
3
  export { TscModule, TscOptions, TscResult, tscEmit };
package/dist/tsc.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./context-Digr9tkU.js";
2
- import { tscEmit } from "./tsc-q7n7-QbP.js";
2
+ import { tscEmit } from "./tsc-DLbQk3B6.js";
3
3
 
4
4
  export { tscEmit };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.16.3",
3
+ "version": "0.16.5",
4
4
  "description": "A Rolldown plugin to generate and bundle dts files.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -40,12 +40,16 @@
40
40
  "access": "public"
41
41
  },
42
42
  "peerDependencies": {
43
+ "@ts-macro/tsc": "^0.3.6",
43
44
  "@typescript/native-preview": ">=7.0.0-dev.20250601.1",
44
45
  "rolldown": "^1.0.0-beta.9",
45
46
  "typescript": "^5.0.0",
46
47
  "vue-tsc": "~3.0.3"
47
48
  },
48
49
  "peerDependenciesMeta": {
50
+ "@ts-macro/tsc": {
51
+ "optional": true
52
+ },
49
53
  "@typescript/native-preview": {
50
54
  "optional": true
51
55
  },
@@ -64,7 +68,8 @@
64
68
  "birpc": "^2.5.0",
65
69
  "debug": "^4.4.1",
66
70
  "dts-resolver": "^2.1.2",
67
- "get-tsconfig": "^4.10.1"
71
+ "get-tsconfig": "^4.10.1",
72
+ "magic-string": "^0.30.19"
68
73
  },
69
74
  "devDependencies": {
70
75
  "@sxzz/eslint-config": "^7.1.4",