rolldown-plugin-dts 0.7.13 → 0.8.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
@@ -68,7 +68,9 @@ interface Options {
68
68
  *
69
69
  * This option is enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
70
70
  */
71
- isolatedDeclaration?: boolean | Omit<IsolatedDeclarationsOptions, 'sourcemap'>
71
+ isolatedDeclarations?:
72
+ | boolean
73
+ | Omit<IsolatedDeclarationsOptions, 'sourcemap'>
72
74
 
73
75
  /** Resolve external types used in dts files from `node_modules` */
74
76
  resolve?: boolean | (string | RegExp)[]
@@ -79,7 +81,7 @@ interface Options {
79
81
 
80
82
  ### Isolated Declarations
81
83
 
82
- The plugin leverages Oxc's `isolatedDeclarations` to generate `.d.ts` files when `isolatedDeclaration` is enabled,
84
+ The plugin leverages Oxc's `isolatedDeclarations` to generate `.d.ts` files when `isolatedDeclarations` is enabled,
83
85
  offering significantly faster performance compared to the `typescript` compiler.
84
86
 
85
87
  ### Single Build for ESM
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ declare function createFakeJsPlugin({ dtsInput }: Pick<Options, "dtsInput">): Pl
7
7
 
8
8
  //#endregion
9
9
  //#region src/generate.d.ts
10
- declare function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration, resolve, emitDtsOnly }: Pick<Options, "isolatedDeclaration" | "resolve" | "emitDtsOnly" | "tsconfig" | "compilerOptions">): Plugin;
10
+ declare function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclarations, resolve, emitDtsOnly }: Pick<Options, "isolatedDeclarations" | "resolve" | "emitDtsOnly" | "tsconfig" | "compilerOptions">): Plugin;
11
11
 
12
12
  //#endregion
13
13
  //#region src/index.d.ts
@@ -45,7 +45,7 @@ interface Options {
45
45
  *
46
46
  * This option is enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
47
47
  */
48
- isolatedDeclaration?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
48
+ isolatedDeclarations?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
49
49
  /** Resolve external types used in dts files from `node_modules` */
50
50
  resolve?: boolean | (string | RegExp)[];
51
51
  }
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { MagicStringAST } from "magic-string-ast";
2
2
  import { parseSync } from "oxc-parser";
3
3
  import path from "node:path";
4
+ import process from "node:process";
4
5
  import { createResolver } from "dts-resolver";
5
6
  import { getTsconfig, parseTsconfig } from "get-tsconfig";
6
7
  import { isolatedDeclaration } from "oxc-transform";
@@ -568,7 +569,7 @@ function getTsModule(dtsMap, tsId) {
568
569
  //#endregion
569
570
  //#region src/generate.ts
570
571
  const meta = { dtsFile: true };
571
- function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration: isolatedDeclaration$1, resolve = false, emitDtsOnly = false }) {
572
+ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclarations, resolve = false, emitDtsOnly = false }) {
572
573
  const dtsMap = new Map();
573
574
  function resolveOptions(cwd) {
574
575
  if (tsconfig === true || tsconfig == null) {
@@ -579,15 +580,16 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
579
580
  ...compilerOptions
580
581
  };
581
582
  } else if (typeof tsconfig === "string") {
583
+ tsconfig = path.resolve(cwd || process.cwd(), tsconfig);
582
584
  const config = parseTsconfig(tsconfig);
583
585
  compilerOptions = {
584
586
  ...config.compilerOptions,
585
587
  ...compilerOptions
586
588
  };
587
589
  }
588
- if (isolatedDeclaration$1 == null) isolatedDeclaration$1 = !!compilerOptions?.isolatedDeclarations;
589
- if (isolatedDeclaration$1 === true) isolatedDeclaration$1 = {};
590
- if (isolatedDeclaration$1 && isolatedDeclaration$1.stripInternal == null) isolatedDeclaration$1.stripInternal = !!compilerOptions?.stripInternal;
590
+ if (isolatedDeclarations == null) isolatedDeclarations = !!compilerOptions?.isolatedDeclarations;
591
+ if (isolatedDeclarations === true) isolatedDeclarations = {};
592
+ if (isolatedDeclarations && isolatedDeclarations.stripInternal == null) isolatedDeclarations.stripInternal = !!compilerOptions?.stripInternal;
591
593
  }
592
594
  /**
593
595
  * A map of input id to output file name
@@ -606,7 +608,7 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
606
608
  async buildStart(options) {
607
609
  resolveOptions(options.cwd);
608
610
  resolver = createResolver({ tsconfig: tsconfig ? tsconfig : void 0 });
609
- if (!isolatedDeclaration$1) initTs();
611
+ if (!isolatedDeclarations) initTs();
610
612
  if (!Array.isArray(options.input)) for (const [name, id] of Object.entries(options.input)) {
611
613
  let resolved = await this.resolve(id, void 0, { skipSelf: true });
612
614
  resolved ||= await this.resolve(`./${id}`, void 0, { skipSelf: true });
@@ -718,8 +720,8 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
718
720
  if (!dtsMap.has(dtsId)) return;
719
721
  const { code, id, isEntry } = dtsMap.get(dtsId);
720
722
  let dtsCode;
721
- if (isolatedDeclaration$1) {
722
- const result = isolatedDeclaration(id, code, isolatedDeclaration$1 === true ? {} : isolatedDeclaration$1);
723
+ if (isolatedDeclarations) {
724
+ const result = isolatedDeclaration(id, code, isolatedDeclarations === true ? {} : isolatedDeclarations);
723
725
  if (result.errors.length) {
724
726
  const [error] = result.errors;
725
727
  return this.error({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.7.13",
3
+ "version": "0.8.1",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",