Skip to content

cocos/gift

This branch is 4 commits ahead of shrinktofit/gift:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ffb910b · Mar 18, 2025

History

69 Commits
Apr 19, 2024
Nov 2, 2020
Aug 20, 2020
Mar 18, 2025
Mar 18, 2025
Aug 20, 2020
Apr 19, 2024
May 22, 2019
Nov 2, 2020
Mar 18, 2025
Mar 18, 2025
Apr 8, 2021
May 6, 2019

Repository files navigation

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:

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:

{
    outFile: "out.js",
}

Bundle:

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.1%
  • JavaScript 2.9%