另一个生成捆绑的工具 .d.ts。 。 。 .
该工具主要用于 https://github.com/cocos-creator/engine (中文(简体) ) 。 。 。 .
例如,这个工具包
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();
}
输入
declare module "my-module" {
export class Vec2 {}
export class Vec3 {}
namespace utils {
export function sin(n: number);
export function cos(n: number);
}
}
开始
如何进行
从 npm 安装此软件包 :
npm install -g tfig
编译您的 TypeScript 工程, 确保 tsc 生成单个声明文件 。 举个例子 有选择权 outFile 内 tsconfig.json数字 :
{
outFile: "out.js",
}
组合 :
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 行参数
投入
未捆绑的路径 *.d.ts 文档。 一般来说,这个文件是由TSC制作的.
根号
要捆绑的根模块的名称 .
产出
输出路径 。 可以是目录或文件 .
名称
生成的模块名称 .