rolldown-plugin-dts 0.7.4 → 0.7.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 +11 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.js +21 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,13 +45,23 @@ interface Options {
|
|
|
45
45
|
*/
|
|
46
46
|
emitDtsOnly?: boolean
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* The path to the `tsconfig.json` file.
|
|
50
|
+
*
|
|
51
|
+
* When set to `false`, the plugin will ignore any `tsconfig.json` file.
|
|
52
|
+
* However, `compilerOptions` can still be specified directly in the options.
|
|
53
|
+
*
|
|
54
|
+
* @default `tsconfig.json`
|
|
55
|
+
*/
|
|
56
|
+
tsconfig?: string | boolean
|
|
57
|
+
|
|
48
58
|
/**
|
|
49
59
|
* The `compilerOptions` for the TypeScript compiler.
|
|
50
|
-
* The default value will be inferred from the `tsconfig.json` file.
|
|
51
60
|
*
|
|
52
61
|
* @see https://www.typescriptlang.org/docs/handbook/compiler-options.html
|
|
53
62
|
*/
|
|
54
63
|
compilerOptions?: TsConfigJson.CompilerOptions
|
|
64
|
+
|
|
55
65
|
/**
|
|
56
66
|
* When `true`, the plugin will generate `.d.ts` files using `oxc-transform`,
|
|
57
67
|
* which is blazingly faster than `typescript` compiler.
|
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({ compilerOptions, isolatedDeclaration, resolve, emitDtsOnly }: Pick<Options, "isolatedDeclaration" | "resolve" | "emitDtsOnly" | "compilerOptions">): Plugin;
|
|
10
|
+
declare function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration, resolve, emitDtsOnly }: Pick<Options, "isolatedDeclaration" | "resolve" | "emitDtsOnly" | "tsconfig" | "compilerOptions">): Plugin;
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/index.d.ts
|
|
@@ -25,8 +25,16 @@ interface Options {
|
|
|
25
25
|
*/
|
|
26
26
|
emitDtsOnly?: boolean;
|
|
27
27
|
/**
|
|
28
|
+
* The path to the `tsconfig.json` file.
|
|
29
|
+
*
|
|
30
|
+
* When set to `false`, the plugin will ignore any `tsconfig.json` file.
|
|
31
|
+
* However, `compilerOptions` can still be specified directly in the options.
|
|
32
|
+
*
|
|
33
|
+
* @default `tsconfig.json`
|
|
34
|
+
*/
|
|
35
|
+
tsconfig?: string | boolean;
|
|
36
|
+
/**
|
|
28
37
|
* The `compilerOptions` for the TypeScript compiler.
|
|
29
|
-
* The default value will be inferred from the `tsconfig.json` file.
|
|
30
38
|
*
|
|
31
39
|
* @see https://www.typescriptlang.org/docs/handbook/compiler-options.html
|
|
32
40
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { MagicStringAST } from "magic-string-ast";
|
|
|
2
2
|
import { parseSync } from "oxc-parser";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createResolver } from "dts-resolver";
|
|
5
|
-
import { getTsconfig } from "get-tsconfig";
|
|
5
|
+
import { getTsconfig, parseTsconfig } from "get-tsconfig";
|
|
6
6
|
import { isolatedDeclaration } from "oxc-transform";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
import Debug from "debug";
|
|
@@ -562,8 +562,26 @@ function tscEmit(module) {
|
|
|
562
562
|
//#endregion
|
|
563
563
|
//#region src/generate.ts
|
|
564
564
|
const meta = { dtsFile: true };
|
|
565
|
-
function createGeneratePlugin({ compilerOptions, isolatedDeclaration: isolatedDeclaration$1, resolve = false, emitDtsOnly = false }) {
|
|
565
|
+
function createGeneratePlugin({ tsconfig, compilerOptions, isolatedDeclaration: isolatedDeclaration$1, resolve = false, emitDtsOnly = false }) {
|
|
566
566
|
const dtsMap = new Map();
|
|
567
|
+
function resolveOptions(cwd) {
|
|
568
|
+
if (tsconfig === true || tsconfig == null) {
|
|
569
|
+
const { config } = getTsconfig(cwd) || {};
|
|
570
|
+
compilerOptions = {
|
|
571
|
+
...config?.compilerOptions,
|
|
572
|
+
...compilerOptions
|
|
573
|
+
};
|
|
574
|
+
} else if (typeof tsconfig === "string") {
|
|
575
|
+
const config = parseTsconfig(tsconfig);
|
|
576
|
+
compilerOptions = {
|
|
577
|
+
...config.compilerOptions,
|
|
578
|
+
...compilerOptions
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
if (isolatedDeclaration$1 == null) isolatedDeclaration$1 = !!compilerOptions?.isolatedDeclarations;
|
|
582
|
+
if (isolatedDeclaration$1 === true) isolatedDeclaration$1 = {};
|
|
583
|
+
if (isolatedDeclaration$1 && isolatedDeclaration$1.stripInternal == null) isolatedDeclaration$1.stripInternal = !!compilerOptions?.stripInternal;
|
|
584
|
+
}
|
|
567
585
|
/**
|
|
568
586
|
* A map of input id to output file name
|
|
569
587
|
*
|
|
@@ -579,13 +597,7 @@ function createGeneratePlugin({ compilerOptions, isolatedDeclaration: isolatedDe
|
|
|
579
597
|
return {
|
|
580
598
|
name: "rolldown-plugin-dts:generate",
|
|
581
599
|
async buildStart(options) {
|
|
582
|
-
|
|
583
|
-
const { config } = getTsconfig(options.cwd) || {};
|
|
584
|
-
compilerOptions = config?.compilerOptions;
|
|
585
|
-
}
|
|
586
|
-
if (isolatedDeclaration$1 == null) isolatedDeclaration$1 = !!compilerOptions?.isolatedDeclarations;
|
|
587
|
-
if (isolatedDeclaration$1 === true) isolatedDeclaration$1 = {};
|
|
588
|
-
if (isolatedDeclaration$1 && isolatedDeclaration$1.stripInternal == null) isolatedDeclaration$1.stripInternal = !!compilerOptions?.stripInternal;
|
|
600
|
+
resolveOptions(options.cwd);
|
|
589
601
|
if (!isolatedDeclaration$1) initTs();
|
|
590
602
|
if (!Array.isArray(options.input)) for (const [name, id] of Object.entries(options.input)) {
|
|
591
603
|
let resolved = await this.resolve(id, void 0, { skipSelf: true });
|