bun-plugin-dtsx 0.21.15 → 0.21.17
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/dist/index.d.ts +16 -0
- package/dist/index.js +7 -23
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BunPlugin } from 'bun';
|
|
2
|
+
import type { DtsGenerationOption } from '@stacksjs/dtsx';
|
|
3
|
+
export type { DtsGenerationOption };
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Bun plugin for generating TypeScript declaration files
|
|
6
|
+
* @param options - Configuration options for DTS generation
|
|
7
|
+
* @returns BunPlugin instance
|
|
8
|
+
*/
|
|
9
|
+
export declare function dts(options?: PluginConfig): BunPlugin;
|
|
10
|
+
/**
|
|
11
|
+
* Configuration interface extending DtsGenerationOption
|
|
12
|
+
*/
|
|
13
|
+
declare interface PluginConfig extends DtsGenerationOption {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
export default dts;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/index.ts
|
|
3
|
-
import
|
|
4
|
-
import path from "path";
|
|
3
|
+
import process from "process";
|
|
5
4
|
import { generate } from "@stacksjs/dtsx";
|
|
6
5
|
function dts(options = {
|
|
7
6
|
root: "./src",
|
|
@@ -11,39 +10,24 @@ function dts(options = {
|
|
|
11
10
|
name: "bun-plugin-dtsx",
|
|
12
11
|
async setup(build) {
|
|
13
12
|
const config = normalizeConfig(options, build);
|
|
14
|
-
if (config.clean && config.outdir) {
|
|
15
|
-
try {
|
|
16
|
-
fs.rmSync(config.outdir, { recursive: true, force: true });
|
|
17
|
-
} catch {}
|
|
18
|
-
fs.mkdirSync(config.outdir, { recursive: true });
|
|
19
|
-
}
|
|
20
13
|
await generate(config);
|
|
21
14
|
}
|
|
22
15
|
};
|
|
23
16
|
}
|
|
24
17
|
function normalizeConfig(options, build) {
|
|
25
|
-
const root = options.root || build
|
|
26
|
-
const outdir = options.outdir || build
|
|
18
|
+
const root = options.root || build.config.root;
|
|
19
|
+
const outdir = options.outdir || build.config.outdir;
|
|
27
20
|
if (!root) {
|
|
28
21
|
throw new Error("[bun-plugin-dtsx] Root directory is required");
|
|
29
22
|
}
|
|
30
|
-
const normalizedEntrypoints = options.entrypoints ?? build?.config?.entrypoints?.map((ep) => {
|
|
31
|
-
if (!ep)
|
|
32
|
-
return ep;
|
|
33
|
-
if (!path.isAbsolute(ep))
|
|
34
|
-
return ep;
|
|
35
|
-
return path.relative(root, ep);
|
|
36
|
-
});
|
|
37
23
|
return {
|
|
38
|
-
|
|
24
|
+
...options,
|
|
25
|
+
cwd: options.cwd || process.cwd(),
|
|
39
26
|
root,
|
|
40
|
-
entrypoints:
|
|
27
|
+
entrypoints: options.entrypoints || ["**/*.ts"],
|
|
41
28
|
outdir,
|
|
42
|
-
keepComments: options.keepComments,
|
|
43
29
|
clean: options.clean,
|
|
44
|
-
tsconfigPath: options.tsconfigPath
|
|
45
|
-
verbose: options.verbose,
|
|
46
|
-
outputStructure: options.outputStructure
|
|
30
|
+
tsconfigPath: options.tsconfigPath
|
|
47
31
|
};
|
|
48
32
|
}
|
|
49
33
|
var src_default = dts;
|
package/package.json
CHANGED