# tfig

> Yet another tool to generate .d.ts bundle.

Latest version **3.3.2** (published 2023-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install tfig
pnpm add tfig
yarn add tfig
bun add tfig
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.2 |
| Published | 2023-09-19 |
| First published | 2019-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 175 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Leslie Leigh |
| Maintainers | shrinktofit, pp_pro |
| Keywords | bundle, declaration, dts |

## Links

- npm: https://www.npmjs.com/package/tfig
- Repository: https://github.com/shrinktofit/gift
- Homepage: https://github.com/shrinktofit/gift#readme
- Issues: https://github.com/shrinktofit/gift/issues
- npm.io page: https://npm.io/package/tfig

## Dependencies (3)

- [yargs](https://npm.io/package/yargs.md) ^13.2.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.1
- [typescript](https://npm.io/package/typescript.md) ^4.9.3

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 3.3.2 (latest) — 2023-09-19
- 2.0.0-beta.1 (beta) — 2020-05-11
- 3.3.1 — 2023-08-18
- 3.2.7 — 2023-05-05
- 3.2.6-alpha.3 — 2022-11-16
- 3.2.6-alpha.2 — 2022-11-16
- 3.2.6-alpha.1 — 2022-11-15
- 3.2.6-alpha.0 — 2022-11-15
- 3.3.0 — 2022-10-17
- 3.2.5 — 2022-06-14
- 3.2.4 — 2022-01-07
- 3.2.3 — 2022-01-06
- 3.2.2 — 2021-11-05
- 3.2.1 — 2021-11-04
- 3.2.0 — 2021-11-04
- … 47 more at https://npm.io/package/tfig/versions

## README

Yet another tool to generate bundled `.d.ts`.

The tool is essentially used in https://github.com/cocos-creator/engine .

For instance, this tool bundles
```
declare module "index" {
    export * from "math";
}
declare module "math" {
    export { Vec2 } from "math/vec2";
    export { Vec3 } from "math/vec3";
    import * as utils from "math/utils";
    export { utils };
}
declare module "math/vec2" {
    export class Vec2 {}
}
declare module "math/vec3" {
    export class Vec3 {}
}
declare module "math/utils" {
    export function sin();
    export function cos();
}
```
into
```
declare module "my-module" {
    export class Vec2 {}
    export class Vec3 {}
    namespace utils {
        export function sin(n: number);
        export function cos(n: number);
    }
}
```

## Getting started

### How-to

Install this package, such as, from npm:
```bash
npm install -g tfig
```

Compile your TypeScript project, make sure to let tsc generate a single declaration file. eg. Have the option `outFile` in `tsconfig.json`:
```json
{
    outFile: "out.js",
}
```

Bundle:
```bash
gift-cli --input "out.d.ts" --root "name-of-the-root-module-in-your-project" --output "path-to-your-output-dir" --name "your-bundle-name"
```

### Comman line arguments

*input*

Path to the unbundled `*.d.ts` file. In general, this file this produced by tsc.

*root*

Name of the root module to bundle.

*output*

Output path. Can be directory or file.

*name*

The generated module name.

---
_Source: https://npm.io/package/tfig · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
