rolldown-plugin-dts 0.7.12 → 0.8.0

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
@@ -244,7 +244,7 @@ function createFakeJsPlugin({ dtsInput }) {
244
244
  entryFileNames: options.entryFileNames ?? (dtsInput ? "[name].ts" : void 0),
245
245
  chunkFileNames(chunk) {
246
246
  const original = (typeof options.chunkFileNames === "function" ? options.chunkFileNames(chunk) : options.chunkFileNames) || "[name]-[hash].js";
247
- if (chunk.name.endsWith(".d")) return filename_js_to_dts(original);
247
+ if (!original.includes(".d") && chunk.name.endsWith(".d")) return filename_js_to_dts(original);
248
248
  return original;
249
249
  }
250
250
  };
@@ -568,7 +568,7 @@ function getTsModule(dtsMap, tsId) {
568
568
  //#endregion
569
569
  //#region src/generate.ts
570
570
  const meta = { dtsFile: true };
571
- function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration: isolatedDeclaration$1, resolve = false, emitDtsOnly = false }) {
571
+ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclarations, resolve = false, emitDtsOnly = false }) {
572
572
  const dtsMap = new Map();
573
573
  function resolveOptions(cwd) {
574
574
  if (tsconfig === true || tsconfig == null) {
@@ -585,9 +585,9 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
585
585
  ...compilerOptions
586
586
  };
587
587
  }
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;
588
+ if (isolatedDeclarations == null) isolatedDeclarations = !!compilerOptions?.isolatedDeclarations;
589
+ if (isolatedDeclarations === true) isolatedDeclarations = {};
590
+ if (isolatedDeclarations && isolatedDeclarations.stripInternal == null) isolatedDeclarations.stripInternal = !!compilerOptions?.stripInternal;
591
591
  }
592
592
  /**
593
593
  * A map of input id to output file name
@@ -606,7 +606,7 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
606
606
  async buildStart(options) {
607
607
  resolveOptions(options.cwd);
608
608
  resolver = createResolver({ tsconfig: tsconfig ? tsconfig : void 0 });
609
- if (!isolatedDeclaration$1) initTs();
609
+ if (!isolatedDeclarations) initTs();
610
610
  if (!Array.isArray(options.input)) for (const [name, id] of Object.entries(options.input)) {
611
611
  let resolved = await this.resolve(id, void 0, { skipSelf: true });
612
612
  resolved ||= await this.resolve(`./${id}`, void 0, { skipSelf: true });
@@ -618,7 +618,7 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
618
618
  ...options,
619
619
  entryFileNames(chunk) {
620
620
  const original = (typeof options.entryFileNames === "function" ? options.entryFileNames(chunk) : options.entryFileNames) || "[name].js";
621
- if (chunk.name.endsWith(".d")) return original.replace(RE_JS, ".$1ts");
621
+ if (!original.includes(".d") && chunk.name.endsWith(".d")) return original.replace(RE_JS, ".$1ts");
622
622
  return original;
623
623
  }
624
624
  };
@@ -718,8 +718,8 @@ function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration:
718
718
  if (!dtsMap.has(dtsId)) return;
719
719
  const { code, id, isEntry } = dtsMap.get(dtsId);
720
720
  let dtsCode;
721
- if (isolatedDeclaration$1) {
722
- const result = isolatedDeclaration(id, code, isolatedDeclaration$1 === true ? {} : isolatedDeclaration$1);
721
+ if (isolatedDeclarations) {
722
+ const result = isolatedDeclaration(id, code, isolatedDeclarations === true ? {} : isolatedDeclarations);
723
723
  if (result.errors.length) {
724
724
  const [error] = result.errors;
725
725
  return this.error({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.7.12",
3
+ "version": "0.8.0",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",