@ssets/dts 1.0.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 +88 -0
- package/dist/bundle-generator.cjs +2836 -0
- package/dist/bundle-generator.d.cts +81 -0
- package/dist/bundle-generator.d.ts +81 -0
- package/dist/bundle-generator.js +2801 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @ssets/dts
|
|
2
|
+
|
|
3
|
+
Simple and focuses on the action of merging multiple TypeScript declaration files (.d.ts) into one.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the package as a development dependency:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @ssets/dts --save-dev
|
|
11
|
+
# or using yarn
|
|
12
|
+
yarn add @ssets/dts --dev
|
|
13
|
+
# or using pnpm
|
|
14
|
+
pnpm add -D @ssets/dts
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
You can use the `generateDtsBundle` function to compile and bundle your declaration files. It accepts an array of entry points and optional compilation configuration.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { generateDtsBundle } from "@ssets/dts";
|
|
23
|
+
import * as fs from "fs";
|
|
24
|
+
|
|
25
|
+
const dtsOutputs = generateDtsBundle([
|
|
26
|
+
{
|
|
27
|
+
filePath: "./src/index.ts",
|
|
28
|
+
output: {
|
|
29
|
+
noBanner: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
// The function returns an array of strings corresponding to each entry point.
|
|
35
|
+
fs.writeFileSync("./dist/index.d.ts", dtsOutputs[0]);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API Reference
|
|
39
|
+
|
|
40
|
+
### `generateDtsBundle(entries, options?)`
|
|
41
|
+
|
|
42
|
+
Generates bundled declaration files for the provided entry points.
|
|
43
|
+
|
|
44
|
+
- `entries`: An array of EntryPointConfig objects.
|
|
45
|
+
- `options` (optional): A `CompilationOptions` object.
|
|
46
|
+
- Returns: `string[]` – An array of bundled `.d.ts` strings in the exact same order as the provided entries.
|
|
47
|
+
|
|
48
|
+
### Configuration Interfaces
|
|
49
|
+
|
|
50
|
+
#### `EntryPointConfig`
|
|
51
|
+
|
|
52
|
+
Defines the configuration for a single entry point.
|
|
53
|
+
|
|
54
|
+
- `filePath` (string): Path to the input file.
|
|
55
|
+
- `libraries` (optional): Options for handling external dependencies (`LibrariesOptions`).
|
|
56
|
+
- `failOnClass` (optional): Fail if the generated dts contains a class declaration.
|
|
57
|
+
- `output` (optional): Formatting and output options (`OutputOptions`).
|
|
58
|
+
|
|
59
|
+
#### `OutputOptions`
|
|
60
|
+
|
|
61
|
+
Controls the behavior of the output generation.
|
|
62
|
+
|
|
63
|
+
- `sortNodes`: Sort output nodes in ascendant order.
|
|
64
|
+
- `umdModuleName`: Name of the UMD module. Emits `export as namespace ModuleName;` if specified.
|
|
65
|
+
- `inlineDeclareGlobals`: Enables inlining of `declare global` statements from inlined files/packages.
|
|
66
|
+
- `inlineDeclareExternals`: Enables inlining of `declare module` statements for global modules.
|
|
67
|
+
- `noBanner`: Removes the "Generated by dts-bundle-generator" style banner/license block from the output.
|
|
68
|
+
- `respectPreserveConstEnum`: Strips the `const` keyword from exported `const enum`s to avoid TS preserving issues.
|
|
69
|
+
- `exportReferencedTypes`: Defaults to `true`. Disable to ensure nodes are exported only if explicitly exported from the root source file.
|
|
70
|
+
|
|
71
|
+
#### `LibrariesOptions`
|
|
72
|
+
|
|
73
|
+
Configures how `node_modules` and `@types` are handled.
|
|
74
|
+
|
|
75
|
+
- `inlinedLibraries`: Array of package names to inline typings from.
|
|
76
|
+
- `importedLibraries`: Array of package names to import typings from. By default, all non-inlined and non-@types libraries are imported.
|
|
77
|
+
- `allowedTypesLibraries`: Array of `@types` packages allowed to be imported via triple-slash references.
|
|
78
|
+
|
|
79
|
+
#### `CompilationOptions`
|
|
80
|
+
|
|
81
|
+
Global options for the compiler host.
|
|
82
|
+
|
|
83
|
+
- `followSymlinks`: (Experimental) Disable resolving symlinks to the original path (defaults to true).
|
|
84
|
+
- `preferredConfigPath`: Explicit path to the `tsconfig.json` file to use.
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
MIT © SSE World
|