rolldown-plugin-dts 0.17.2 → 0.17.4

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
@@ -91,6 +91,15 @@ By default, dependencies are external, resulting in `import { Type } from 'some-
91
91
  - `false`: (Default) Keeps all dependencies external.
92
92
  - `(string | RegExp)[]`: Bundles only dependencies matching the provided strings or regular expressions (e.g. `['pkg-a', /^@scope\//]`).
93
93
 
94
+ #### `resolver`
95
+
96
+ Specifies a resolver to resolve type definitions, especially for `node_modules`.
97
+
98
+ - `'oxc'`: Uses Oxc's module resolution, which is faster and more efficient.
99
+ - `'tsc'`: Uses TypeScript's native module resolution, which may be more compatible with complex setups, but slower.
100
+
101
+ Defaults to `'oxc'`.
102
+
94
103
  #### `cjsDefault`
95
104
 
96
105
  Determines how the default export is emitted.
@@ -107,6 +116,15 @@ Content to be added at the top of each generated `.d.ts` file.
107
116
 
108
117
  Content to be added at the bottom of each generated `.d.ts` file.
109
118
 
119
+ #### `sideEffects`
120
+
121
+ Indicates whether the generated `.d.ts` files have side effects.
122
+
123
+ - If set to `true`, Rolldown will treat the `.d.ts` files as having side effects during tree-shaking.
124
+ - If set to `false`, Rolldown may consider the `.d.ts` files as side-effect-free, potentially removing them if they are not imported.
125
+
126
+ **Default:** false
127
+
110
128
  ### `tsc` Options
111
129
 
112
130
  > [!NOTE]
@@ -1,2 +1,2 @@
1
- import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-0s1tyon-.js";
1
+ import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-GAo446AD.mjs";
2
2
  export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn };
@@ -1,3 +1,3 @@
1
- import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-DDjuEak0.js";
1
+ import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-DhMOFFZT.mjs";
2
2
 
3
3
  export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn };
@@ -1,4 +1,4 @@
1
- import { r as TscContext } from "./context-Cf8MAZaX.js";
1
+ import { r as TscContext } from "./context-CJDCoB2H.mjs";
2
2
  import { TsConfigJson } from "get-tsconfig";
3
3
  import ts from "typescript";
4
4
  import { SourceMapInput } from "rolldown";
@@ -1,4 +1,4 @@
1
- import { a as RE_JSON, c as RE_VUE, i as RE_JS, n as RE_DTS, o as RE_NODE_MODULES, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS } from "./filename-0s1tyon-.js";
1
+ import { a as RE_JSON, c as RE_VUE, i as RE_JS, n as RE_DTS, o as RE_NODE_MODULES, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS } from "./filename-GAo446AD.mjs";
2
2
  import { IsolatedDeclarationsOptions } from "rolldown/experimental";
3
3
  import { TsConfigJson } from "get-tsconfig";
4
4
  import { AddonFunction, Plugin } from "rolldown";
@@ -57,6 +57,15 @@ interface GeneralOptions {
57
57
  */
58
58
  resolve?: boolean | (string | RegExp)[];
59
59
  /**
60
+ * Specifies a resolver to resolve type definitions, especially for `node_modules`.
61
+ *
62
+ * - `'oxc'`: Uses Oxc's module resolution, which is faster and more efficient.
63
+ * - `'tsc'`: Uses TypeScript's native module resolution, which may be more compatible with complex setups, but slower.
64
+ *
65
+ * @default 'oxc'
66
+ */
67
+ resolver?: "oxc" | "tsc";
68
+ /**
60
69
  * Determines how the default export is emitted.
61
70
  *
62
71
  * If set to `true`, and you are only exporting a single item using `export default ...`,
@@ -64,6 +73,14 @@ interface GeneralOptions {
64
73
  * This is useful for compatibility with CommonJS.
65
74
  */
66
75
  cjsDefault?: boolean;
76
+ /**
77
+ * Indicates whether the generated `.d.ts` files have side effects.
78
+ * - If set to `true`, Rolldown will treat the `.d.ts` files as having side effects during tree-shaking.
79
+ * - If set to `false`, Rolldown may consider the `.d.ts` files as side-effect-free, potentially removing them if they are not imported.
80
+ *
81
+ * @default false
82
+ */
83
+ sideEffects?: boolean;
67
84
  }
68
85
  interface TscOptions {
69
86
  /**
@@ -187,9 +204,11 @@ declare function resolveOptions({
187
204
  compilerOptions,
188
205
  sourcemap,
189
206
  resolve,
207
+ resolver,
190
208
  cjsDefault,
191
209
  banner,
192
210
  footer,
211
+ sideEffects,
193
212
  build,
194
213
  incremental,
195
214
  vue,
@@ -205,8 +224,9 @@ declare function resolveOptions({
205
224
  //#region src/fake-js.d.ts
206
225
  declare function createFakeJsPlugin({
207
226
  sourcemap,
208
- cjsDefault
209
- }: Pick<OptionsResolved, "sourcemap" | "cjsDefault">): Plugin;
227
+ cjsDefault,
228
+ sideEffects
229
+ }: Pick<OptionsResolved, "sourcemap" | "cjsDefault" | "sideEffects">): Plugin;
210
230
  //#endregion
211
231
  //#region src/generate.d.ts
212
232
  declare function createGeneratePlugin({
@@ -1,6 +1,6 @@
1
1
  const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
2
- import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-DDjuEak0.js";
3
- import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-BacUE4pM.js";
2
+ import { a as RE_JSON, c as RE_VUE, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-DhMOFFZT.mjs";
3
+ import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-Db5EuGKU.mjs";
4
4
  const Debug = __cjs_require("debug");
5
5
  import MagicString from "magic-string";
6
6
  const {
@@ -10,7 +10,7 @@ const {
10
10
  parse
11
11
  } = __cjs_require("@babel/parser");
12
12
  const t = __cjs_require("@babel/types");
13
- import { isDeclarationType, isTypeOf, resolveString } from "ast-kit";
13
+ import { isDeclarationType, isIdentifierOf, isTypeOf, resolveString, walkAST } from "ast-kit";
14
14
  const {
15
15
  fork,
16
16
  spawn
@@ -63,10 +63,10 @@ function createBannerPlugin({ banner, footer }) {
63
63
 
64
64
  //#endregion
65
65
  //#region src/dts-input.ts
66
- function createDtsInputPlugin() {
66
+ function createDtsInputPlugin({ sideEffects }) {
67
67
  return {
68
68
  name: "rolldown-plugin-dts:dts-input",
69
- options(options) {
69
+ options: sideEffects === false ? (options) => {
70
70
  return {
71
71
  treeshake: options.treeshake === false ? false : {
72
72
  ...options.treeshake === true ? {} : options.treeshake,
@@ -74,7 +74,7 @@ function createDtsInputPlugin() {
74
74
  },
75
75
  ...options
76
76
  };
77
- },
77
+ } : void 0,
78
78
  outputOptions(options) {
79
79
  return {
80
80
  ...options,
@@ -96,195 +96,9 @@ function createDtsInputPlugin() {
96
96
  };
97
97
  }
98
98
 
99
- //#endregion
100
- //#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/walker.js
101
- /**
102
- * @typedef { import('estree').Node} Node
103
- * @typedef {{
104
- * skip: () => void;
105
- * remove: () => void;
106
- * replace: (node: Node) => void;
107
- * }} WalkerContext
108
- */
109
- var WalkerBase = class {
110
- constructor() {
111
- /** @type {boolean} */
112
- this.should_skip = false;
113
- /** @type {boolean} */
114
- this.should_remove = false;
115
- /** @type {Node | null} */
116
- this.replacement = null;
117
- /** @type {WalkerContext} */
118
- this.context = {
119
- skip: () => this.should_skip = true,
120
- remove: () => this.should_remove = true,
121
- replace: (node) => this.replacement = node
122
- };
123
- }
124
- /**
125
- * @template {Node} Parent
126
- * @param {Parent | null | undefined} parent
127
- * @param {keyof Parent | null | undefined} prop
128
- * @param {number | null | undefined} index
129
- * @param {Node} node
130
- */
131
- replace(parent, prop, index, node) {
132
- if (parent && prop) if (index != null)
133
- /** @type {Array<Node>} */ parent[prop][index] = node;
134
- else
135
- /** @type {Node} */ parent[prop] = node;
136
- }
137
- /**
138
- * @template {Node} Parent
139
- * @param {Parent | null | undefined} parent
140
- * @param {keyof Parent | null | undefined} prop
141
- * @param {number | null | undefined} index
142
- */
143
- remove(parent, prop, index) {
144
- if (parent && prop) if (index !== null && index !== void 0)
145
- /** @type {Array<Node>} */ parent[prop].splice(index, 1);
146
- else delete parent[prop];
147
- }
148
- };
149
-
150
- //#endregion
151
- //#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/sync.js
152
- /**
153
- * @typedef { import('estree').Node} Node
154
- * @typedef { import('./walker.js').WalkerContext} WalkerContext
155
- * @typedef {(
156
- * this: WalkerContext,
157
- * node: Node,
158
- * parent: Node | null,
159
- * key: string | number | symbol | null | undefined,
160
- * index: number | null | undefined
161
- * ) => void} SyncHandler
162
- */
163
- var SyncWalker = class extends WalkerBase {
164
- /**
165
- *
166
- * @param {SyncHandler} [enter]
167
- * @param {SyncHandler} [leave]
168
- */
169
- constructor(enter, leave) {
170
- super();
171
- /** @type {boolean} */
172
- this.should_skip = false;
173
- /** @type {boolean} */
174
- this.should_remove = false;
175
- /** @type {Node | null} */
176
- this.replacement = null;
177
- /** @type {WalkerContext} */
178
- this.context = {
179
- skip: () => this.should_skip = true,
180
- remove: () => this.should_remove = true,
181
- replace: (node) => this.replacement = node
182
- };
183
- /** @type {SyncHandler | undefined} */
184
- this.enter = enter;
185
- /** @type {SyncHandler | undefined} */
186
- this.leave = leave;
187
- }
188
- /**
189
- * @template {Node} Parent
190
- * @param {Node} node
191
- * @param {Parent | null} parent
192
- * @param {keyof Parent} [prop]
193
- * @param {number | null} [index]
194
- * @returns {Node | null}
195
- */
196
- visit(node, parent, prop, index) {
197
- if (node) {
198
- if (this.enter) {
199
- const _should_skip = this.should_skip;
200
- const _should_remove = this.should_remove;
201
- const _replacement = this.replacement;
202
- this.should_skip = false;
203
- this.should_remove = false;
204
- this.replacement = null;
205
- this.enter.call(this.context, node, parent, prop, index);
206
- if (this.replacement) {
207
- node = this.replacement;
208
- this.replace(parent, prop, index, node);
209
- }
210
- if (this.should_remove) this.remove(parent, prop, index);
211
- const skipped = this.should_skip;
212
- const removed = this.should_remove;
213
- this.should_skip = _should_skip;
214
- this.should_remove = _should_remove;
215
- this.replacement = _replacement;
216
- if (skipped) return node;
217
- if (removed) return null;
218
- }
219
- /** @type {keyof Node} */
220
- let key;
221
- for (key in node) {
222
- /** @type {unknown} */
223
- const value = node[key];
224
- if (value && typeof value === "object") {
225
- if (Array.isArray(value)) {
226
- const nodes = value;
227
- for (let i = 0; i < nodes.length; i += 1) {
228
- const item = nodes[i];
229
- if (isNode(item)) {
230
- if (!this.visit(item, node, key, i)) i--;
231
- }
232
- }
233
- } else if (isNode(value)) this.visit(value, node, key, null);
234
- }
235
- }
236
- if (this.leave) {
237
- const _replacement = this.replacement;
238
- const _should_remove = this.should_remove;
239
- this.replacement = null;
240
- this.should_remove = false;
241
- this.leave.call(this.context, node, parent, prop, index);
242
- if (this.replacement) {
243
- node = this.replacement;
244
- this.replace(parent, prop, index, node);
245
- }
246
- if (this.should_remove) this.remove(parent, prop, index);
247
- const removed = this.should_remove;
248
- this.replacement = _replacement;
249
- this.should_remove = _should_remove;
250
- if (removed) return null;
251
- }
252
- }
253
- return node;
254
- }
255
- };
256
- /**
257
- * Ducktype a node.
258
- *
259
- * @param {unknown} value
260
- * @returns {value is Node}
261
- */
262
- function isNode(value) {
263
- return value !== null && typeof value === "object" && "type" in value && typeof value.type === "string";
264
- }
265
-
266
- //#endregion
267
- //#region node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/index.js
268
- /**
269
- * @typedef {import('estree').Node} Node
270
- * @typedef {import('./sync.js').SyncHandler} SyncHandler
271
- * @typedef {import('./async.js').AsyncHandler} AsyncHandler
272
- */
273
- /**
274
- * @param {Node} ast
275
- * @param {{
276
- * enter?: SyncHandler
277
- * leave?: SyncHandler
278
- * }} walker
279
- * @returns {Node | null}
280
- */
281
- function walk(ast, { enter, leave }) {
282
- return new SyncWalker(enter, leave).visit(ast, null);
283
- }
284
-
285
99
  //#endregion
286
100
  //#region src/fake-js.ts
287
- function createFakeJsPlugin({ sourcemap, cjsDefault }) {
101
+ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
288
102
  let symbolIdx = 0;
289
103
  const identifierMap = Object.create(null);
290
104
  const symbolMap = /* @__PURE__ */ new Map();
@@ -325,7 +139,8 @@ function createFakeJsPlugin({ sourcemap, cjsDefault }) {
325
139
  function transform(code, id) {
326
140
  const file = parse(code, {
327
141
  plugins: [["typescript", { dts: true }]],
328
- sourceType: "module"
142
+ sourceType: "module",
143
+ errorRecovery: true
329
144
  });
330
145
  const { program, comments } = file;
331
146
  const typeOnlyIds = [];
@@ -404,6 +219,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault }) {
404
219
  setStmt(runtimeAssignment);
405
220
  } else setDecl(runtimeAssignment);
406
221
  }
222
+ if (sideEffects) appendStmts.push(t.expressionStatement(t.callExpression(t.identifier("sideEffect"), [])));
407
223
  program.body = [
408
224
  ...Array.from(namespaceStmts.values()).map(({ stmt }) => stmt),
409
225
  ...program.body,
@@ -502,7 +318,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault }) {
502
318
  */
503
319
  function collectParams(node) {
504
320
  const typeParams = [];
505
- walk(node, { leave(node$1) {
321
+ walkAST(node, { leave(node$1) {
506
322
  if ("typeParameters" in node$1 && node$1.typeParameters?.type === "TSTypeParameterDeclaration") typeParams.push(...node$1.typeParameters.params);
507
323
  } });
508
324
  const paramMap = /* @__PURE__ */ new Map();
@@ -520,7 +336,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault }) {
520
336
  function collectDependencies(node, namespaceStmts) {
521
337
  const deps = /* @__PURE__ */ new Set();
522
338
  const seen = /* @__PURE__ */ new Set();
523
- walk(node, { leave(node$1) {
339
+ walkAST(node, { leave(node$1) {
524
340
  if (node$1.type === "ExportNamedDeclaration") {
525
341
  for (const specifier of node$1.specifiers) if (specifier.type === "ExportSpecifier") addDependency(specifier.local);
526
342
  } else if (node$1.type === "TSInterfaceDeclaration" && node$1.extends) for (const heritage of node$1.extends || []) addDependency(TSEntityNameToRuntime(heritage.expression));
@@ -613,7 +429,7 @@ function isRuntimeBindingArrayElements(elements) {
613
429
  return t.isNumericLiteral(symbolId) && t.isArrowFunctionExpression(deps) && (!effect || t.isCallExpression(effect));
614
430
  }
615
431
  function isThisExpression(node) {
616
- return node.type === "Identifier" && node.name === "this" || node.type === "MemberExpression" && isThisExpression(node.object);
432
+ return isIdentifierOf(node, "this") || node.type === "MemberExpression" && isThisExpression(node.object);
617
433
  }
618
434
  function TSEntityNameToRuntime(node) {
619
435
  if (node.type === "Identifier") return node;
@@ -625,7 +441,7 @@ function getIdFromTSEntityName(node) {
625
441
  return getIdFromTSEntityName(node.left);
626
442
  }
627
443
  function isReferenceId(node) {
628
- return !!node && (node.type === "Identifier" || node.type === "MemberExpression");
444
+ return isTypeOf(node, ["Identifier", "MemberExpression"]);
629
445
  }
630
446
  function isHelperImport(node) {
631
447
  return node.type === "ImportDeclaration" && node.specifiers.length === 1 && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.imported.type === "Identifier" && ["__export", "__reExport"].includes(spec.local.name));
@@ -696,7 +512,7 @@ function patchTsNamespace(nodes) {
696
512
  function patchReExport(nodes) {
697
513
  const exportsNames = /* @__PURE__ */ new Map();
698
514
  for (const [i, node] of nodes.entries()) if (node.type === "ImportDeclaration" && node.specifiers.length === 1 && node.specifiers[0].type === "ImportSpecifier" && node.specifiers[0].local.type === "Identifier" && node.specifiers[0].local.name.endsWith("_exports")) exportsNames.set(node.specifiers[0].local.name, node.specifiers[0].local.name);
699
- else if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression" && node.expression.callee.type === "Identifier" && node.expression.callee.name === "__reExport") {
515
+ else if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression" && isIdentifierOf(node.expression.callee, "__reExport")) {
700
516
  const args = node.expression.arguments;
701
517
  exportsNames.set(args[0].name, args[1].name);
702
518
  } else if (node.type === "VariableDeclaration" && node.declarations.length === 1 && node.declarations[0].init?.type === "MemberExpression" && node.declarations[0].init.object.type === "Identifier" && exportsNames.has(node.declarations[0].init.object.name)) nodes[i] = {
@@ -822,7 +638,7 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd,
822
638
  on: (fn) => childProcess.on("message", fn)
823
639
  });
824
640
  } else {
825
- tscModule = await import("./tsc.js");
641
+ tscModule = await import("./tsc.mjs");
826
642
  if (newContext) tscContext = createContext();
827
643
  }
828
644
  if (!Array.isArray(options.input)) for (const [name, id] of Object.entries(options.input)) {
@@ -964,7 +780,6 @@ export { __json_default_export as default }`;
964
780
  }
965
781
  return {
966
782
  code: dtsCode || "",
967
- moduleSideEffects: false,
968
783
  map
969
784
  };
970
785
  }
@@ -1010,11 +825,14 @@ function collectJsonExportMap(code) {
1010
825
  const exportMap = /* @__PURE__ */ new Map();
1011
826
  const { program } = parse(code, {
1012
827
  sourceType: "module",
1013
- plugins: [["typescript", { dts: true }]]
828
+ plugins: [["typescript", { dts: true }]],
829
+ errorRecovery: true
1014
830
  });
1015
831
  for (const decl of program.body) if (decl.type === "ExportNamedDeclaration") {
1016
- if (decl.declaration && decl.declaration.type === "VariableDeclaration") {
1017
- for (const vdecl of decl.declaration.declarations) if (vdecl.id.type === "Identifier") exportMap.set(vdecl.id.name, vdecl.id.name);
832
+ if (decl.declaration) {
833
+ if (decl.declaration.type === "VariableDeclaration") {
834
+ for (const vdecl of decl.declaration.declarations) if (vdecl.id.type === "Identifier") exportMap.set(vdecl.id.name, vdecl.id.name);
835
+ } else if (decl.declaration.type === "TSModuleDeclaration" && decl.declaration.id.type === "Identifier") exportMap.set(decl.declaration.id.name, decl.declaration.id.name);
1018
836
  } else if (decl.specifiers.length) {
1019
837
  for (const spec of decl.specifiers) if (spec.type === "ExportSpecifier" && spec.exported.type === "Identifier") exportMap.set(spec.exported.name, spec.local.type === "Identifier" ? spec.local.name : spec.exported.name);
1020
838
  }
@@ -1037,7 +855,7 @@ function collectJsonExports(code) {
1037
855
  //#endregion
1038
856
  //#region src/options.ts
1039
857
  let warnedTsgo = false;
1040
- 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 }) {
858
+ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap, resolve = false, resolver = "oxc", cjsDefault = false, banner, footer, sideEffects = false, build = false, incremental = false, vue = false, tsMacro = false, parallel = false, eager = false, newContext = false, emitJs, oxc, tsgo = false }) {
1041
859
  let resolvedTsconfig;
1042
860
  if (tsconfig === true || tsconfig == null) {
1043
861
  const { config, path: path$1 } = getTsconfig(cwd) || {};
@@ -1085,9 +903,11 @@ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = f
1085
903
  tsconfigRaw,
1086
904
  sourcemap,
1087
905
  resolve,
906
+ resolver,
1088
907
  cjsDefault,
1089
908
  banner,
1090
909
  footer,
910
+ sideEffects,
1091
911
  build,
1092
912
  incremental,
1093
913
  vue,
@@ -1106,12 +926,13 @@ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = f
1106
926
  function isSourceFile(id) {
1107
927
  return RE_TS.test(id) || RE_VUE.test(id) || RE_JSON.test(id);
1108
928
  }
1109
- function createDtsResolvePlugin({ tsconfig, resolve }) {
929
+ function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolve, resolver, sideEffects }) {
1110
930
  const baseDtsResolver = createResolver({
1111
931
  tsconfig,
1112
932
  resolveNodeModules: !!resolve,
1113
933
  ResolverFactory
1114
934
  });
935
+ const moduleSideEffects = sideEffects ? true : null;
1115
936
  return {
1116
937
  name: "rolldown-plugin-dts:resolver",
1117
938
  resolveId: {
@@ -1121,17 +942,23 @@ function createDtsResolvePlugin({ tsconfig, resolve }) {
1121
942
  const external = {
1122
943
  id,
1123
944
  external: true,
1124
- moduleSideEffects: false
945
+ moduleSideEffects: sideEffects
1125
946
  };
1126
947
  if (RE_CSS.test(id)) return external;
1127
948
  const rolldownResolution = await this.resolve(id, importer, options);
1128
- const dtsResolution = resolveDtsPath(id, importer, rolldownResolution);
949
+ const dtsResolution = await resolveDtsPath(id, importer, rolldownResolution);
1129
950
  if (!dtsResolution) return isFilePath(id) ? null : external;
1130
951
  if (RE_NODE_MODULES.test(dtsResolution) && !shouldBundleNodeModule(id) && (!RE_NODE_MODULES.test(importer) || rolldownResolution?.external)) return external;
1131
- if (RE_DTS.test(dtsResolution)) return dtsResolution;
952
+ if (RE_DTS.test(dtsResolution)) return {
953
+ id: dtsResolution,
954
+ moduleSideEffects
955
+ };
1132
956
  if (isSourceFile(dtsResolution)) {
1133
957
  await this.load({ id: dtsResolution });
1134
- return filename_to_dts(dtsResolution);
958
+ return {
959
+ id: filename_to_dts(dtsResolution),
960
+ moduleSideEffects
961
+ };
1135
962
  }
1136
963
  }
1137
964
  }
@@ -1140,8 +967,12 @@ function createDtsResolvePlugin({ tsconfig, resolve }) {
1140
967
  if (typeof resolve === "boolean") return resolve;
1141
968
  return resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
1142
969
  }
1143
- function resolveDtsPath(id, importer, rolldownResolution) {
1144
- let dtsPath = baseDtsResolver(id, importer);
970
+ async function resolveDtsPath(id, importer, rolldownResolution) {
971
+ let dtsPath;
972
+ if (resolver === "tsc") {
973
+ const { tscResolve } = await import("./resolver-DymnxKPB.mjs");
974
+ dtsPath = tscResolve(id, importer, cwd, tsconfig, tsconfigRaw);
975
+ } else dtsPath = baseDtsResolver(id, importer);
1145
976
  if (dtsPath) dtsPath = path.normalize(dtsPath);
1146
977
  if (!dtsPath || !isSourceFile(dtsPath)) {
1147
978
  if (rolldownResolution && isFilePath(rolldownResolution.id) && isSourceFile(rolldownResolution.id) && !rolldownResolution.external) return rolldownResolution.id;
@@ -1162,7 +993,7 @@ function dts(options = {}) {
1162
993
  const resolved = resolveOptions(options);
1163
994
  debug("resolved dts options %o", resolved);
1164
995
  const plugins = [];
1165
- if (options.dtsInput) plugins.push(createDtsInputPlugin());
996
+ if (options.dtsInput) plugins.push(createDtsInputPlugin(resolved));
1166
997
  else plugins.push(createGeneratePlugin(resolved));
1167
998
  plugins.push(createDtsResolvePlugin(resolved), createFakeJsPlugin(resolved));
1168
999
  if (options.banner || options.footer) plugins.push(createBannerPlugin(resolved));
@@ -0,0 +1,17 @@
1
+ const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
2
+ const Debug = __cjs_require("debug");
3
+ const path = globalThis.process.getBuiltinModule("node:path");
4
+ const ts = __cjs_require("typescript");
5
+
6
+ //#region src/tsc/resolver.ts
7
+ const debug = Debug("rolldown-plugin-dts:tsc-resolver");
8
+ function tscResolve(id, importer, cwd, tsconfig, tsconfigRaw, reference) {
9
+ const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
10
+ const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, ts.sys, baseDir);
11
+ const resolved = ts.bundlerModuleNameResolver(id, importer, parsedConfig.options, ts.sys, void 0, reference);
12
+ debug(`tsc resolving id "%s" from "%s" -> %O`, id, importer, resolved.resolvedModule);
13
+ return resolved.resolvedModule?.resolvedFileName;
14
+ }
15
+
16
+ //#endregion
17
+ export { tscResolve };
@@ -1,5 +1,5 @@
1
1
  const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
2
- import { n as globalContext } from "./context-BacUE4pM.js";
2
+ import { n as globalContext } from "./context-Db5EuGKU.mjs";
3
3
  const {
4
4
  createRequire
5
5
  } = globalThis.process.getBuiltinModule("node:module");
@@ -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-Cf8MAZaX.js";
1
+ import { a as globalContext, i as createContext, n as SourceFileToProjectMap, o as invalidateContextFile, r as TscContext, t as ParsedProject } from "./context-CJDCoB2H.mjs";
2
2
  export { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile };
@@ -0,0 +1,3 @@
1
+ import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-Db5EuGKU.mjs";
2
+
3
+ export { createContext, globalContext, invalidateContextFile };
@@ -1,5 +1,5 @@
1
- import "./context-Cf8MAZaX.js";
2
- import { t as tscEmit } from "./index-UvaKF8Pg.js";
1
+ import "./context-CJDCoB2H.mjs";
2
+ import { t as tscEmit } from "./index-C4bAW0sP.mjs";
3
3
 
4
4
  //#region src/tsc/worker.d.ts
5
5
  declare const functions: {
@@ -1,5 +1,5 @@
1
- import { t as tscEmit } from "./tsc--GG3zA2e.js";
2
- import "./context-BacUE4pM.js";
1
+ import { t as tscEmit } from "./tsc-Oohh5fvr.mjs";
2
+ import "./context-Db5EuGKU.mjs";
3
3
  const process = globalThis.process;
4
4
  import { createBirpc } from "birpc";
5
5
 
package/dist/tsc.d.mts ADDED
@@ -0,0 +1,3 @@
1
+ import "./context-CJDCoB2H.mjs";
2
+ import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-C4bAW0sP.mjs";
3
+ export { TscModule, TscOptions, TscResult, tscEmit };
package/dist/tsc.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { t as tscEmit } from "./tsc-Oohh5fvr.mjs";
2
+ import "./context-Db5EuGKU.mjs";
3
+
4
+ export { tscEmit };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.17.2",
3
+ "version": "0.17.4",
4
4
  "description": "A Rolldown plugin to generate and bundle dts files.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -25,15 +25,15 @@
25
25
  "files": [
26
26
  "dist"
27
27
  ],
28
- "main": "./dist/index.js",
29
- "module": "./dist/index.js",
30
- "types": "./dist/index.d.ts",
28
+ "main": "./dist/index.mjs",
29
+ "module": "./dist/index.mjs",
30
+ "types": "./dist/index.d.mts",
31
31
  "exports": {
32
- ".": "./dist/index.js",
33
- "./filename": "./dist/filename.js",
34
- "./tsc": "./dist/tsc.js",
35
- "./tsc-context": "./dist/tsc-context.js",
36
- "./tsc-worker": "./dist/tsc-worker.js",
32
+ ".": "./dist/index.mjs",
33
+ "./filename": "./dist/filename.mjs",
34
+ "./tsc": "./dist/tsc.mjs",
35
+ "./tsc-context": "./dist/tsc-context.mjs",
36
+ "./tsc-worker": "./dist/tsc-worker.mjs",
37
37
  "./package.json": "./package.json"
38
38
  },
39
39
  "publishConfig": {
@@ -64,38 +64,37 @@
64
64
  "@babel/generator": "^7.28.5",
65
65
  "@babel/parser": "^7.28.5",
66
66
  "@babel/types": "^7.28.5",
67
- "ast-kit": "^2.1.3",
68
- "birpc": "^2.6.1",
67
+ "ast-kit": "^2.2.0",
68
+ "birpc": "^2.7.0",
69
69
  "debug": "^4.4.3",
70
70
  "dts-resolver": "^2.1.2",
71
71
  "get-tsconfig": "^4.13.0",
72
72
  "magic-string": "^0.30.21"
73
73
  },
74
74
  "devDependencies": {
75
- "@sxzz/eslint-config": "^7.2.7",
75
+ "@sxzz/eslint-config": "^7.2.8",
76
76
  "@sxzz/prettier-config": "^2.2.4",
77
77
  "@sxzz/test-utils": "^0.5.12",
78
78
  "@types/babel__generator": "^7.27.0",
79
79
  "@types/debug": "^4.1.12",
80
- "@types/node": "^24.9.1",
81
- "@typescript/native-preview": "7.0.0-dev.20251027.1",
80
+ "@types/node": "^24.10.0",
81
+ "@typescript/native-preview": "7.0.0-dev.20251108.1",
82
82
  "@volar/typescript": "^2.4.23",
83
- "@vue/language-core": "^3.1.2",
84
- "arktype": "^2.1.23",
83
+ "@vue/language-core": "^3.1.3",
84
+ "arktype": "^2.1.25",
85
85
  "bumpp": "^10.3.1",
86
86
  "diff": "^8.0.2",
87
- "eslint": "^9.38.0",
88
- "estree-walker": "^3.0.3",
87
+ "eslint": "^9.39.1",
89
88
  "prettier": "^3.6.2",
90
- "rolldown": "^1.0.0-beta.45",
89
+ "rolldown": "^1.0.0-beta.47",
91
90
  "rolldown-plugin-require-cjs": "^0.3.1",
92
91
  "rollup-plugin-dts": "^6.2.3",
93
92
  "tinyglobby": "^0.2.15",
94
- "tsdown": "^0.15.11",
93
+ "tsdown": "^0.16.1",
95
94
  "typescript": "^5.9.3",
96
- "vitest": "^4.0.4",
97
- "vue": "^3.5.22",
98
- "vue-tsc": "^3.1.2"
95
+ "vitest": "^4.0.8",
96
+ "vue": "^3.5.24",
97
+ "vue-tsc": "^3.1.3"
99
98
  },
100
99
  "engines": {
101
100
  "node": ">=20.18.0"
@@ -1,3 +0,0 @@
1
- import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-BacUE4pM.js";
2
-
3
- export { createContext, globalContext, invalidateContextFile };
package/dist/tsc.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import "./context-Cf8MAZaX.js";
2
- import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-UvaKF8Pg.js";
3
- export { TscModule, TscOptions, TscResult, tscEmit };
package/dist/tsc.js DELETED
@@ -1,4 +0,0 @@
1
- import { t as tscEmit } from "./tsc--GG3zA2e.js";
2
- import "./context-BacUE4pM.js";
3
-
4
- export { tscEmit };