Miss any of our Open RFC calls?Watch the recordings here! »

tsbundler

3.0.0-beta.7 • Public • Published

npm version Build Status

TsBundler

TsBundler is a custom Typescript transform that builds single module bundles.

Top Features

  • Bundling of external Typescript modules into a single file, single module bundle.
  • Bundle file output can be to output to memory, disk or gulp (vinyl file stream)

TsBundler Wiki

Additional details can be found on the TsBundler wiki.

Typescript Single Module Bundles

TsBundler supports a "bundles" property within the Typescript project configuration json file. The "bundles" property may contain a list of named bundles. Each bundle must provide an array of source files and may optionally specify bundle configuration settings. The Typescript source file and its dependencies are packaged as a single Typescript file and output with the bundle name. The Typescript bundle is compiled to a single js javascript file and a single d.ts declaration file.

The following is a sample tsconfig.json showing the "bundles" property:

{
    "compilerOptions": {
        "module": "amd",
        "target": "es5",
        "noResolve": false,
        "declaration": true,
        "diagnostics": true
    },

    "files": [
        "index.ts",
        "page.ts",
        "common.ts",
        "plugin.ts"
    ],
    
    "bundles": {
        "app": {
            "files": [ "index.ts" ]
        },
        "components": {
            "files": [
                "page.ts",
                "plugin.ts"
            ],
            "config": {
                "declaration": true,
                "outDir": "./bundles",
                "minify": true  
            }
        }
    }
}

Node API

    interface BundlerOptions {
        verbose?: boolean;
        logLevel?: number;
        outputToDisk?: string;
    }
    
    interface BuildResult {
        errors: ts.Diagnostic[];
        bundleOutput?: ts2js.CompilerResult[];
        succeeded(): boolean;
    }

    interface BundleBuilder {
        build( buildCompleted: (result: BuildResult) => void): void;
        src(): stream.Readable;
    }
    
    function builder(configFilePath: string, bundlerOptions?: BundlerOptions, buildCompleted?: (result: BuildResult) => void): BundleBuilder;

How to install

npm install tsbundler

Building TsBundler

TsBundler depends on NPM as a package manager and Gulp as a build tool. If you haven't already, you'll need to install both these tools in order to build TsBundler.

Once Gulp is installed, you can build it with the following commands:

npm install
gulp build

Install

npm i tsbundler

DownloadsWeekly Downloads

1

Version

3.0.0-beta.7

License

MIT

Unpacked Size

72.9 kB

Total Files

5

Last publish

Collaborators

  • avatar