Version: 1.7.0

Build

Rollup and Babel are the primary tools that power builds in ts-engine.

Two types of packages are fully supported by ts-engine, Node.js applications and libraries. Because each type of package has different requirements at build time the type of the package must be provided when building.

Building a Node.js application

To build a Node.js application run the following command:

ts-engine build --node-app

A Node.js application produces a single output file.

Entry filesOutput filesModule type
src/main.tsdist/main.jsCommonJs

Watching for changes

The build command also supports watching for changes to source code and rebuilding automatically when changes occur.

To build and trigger watch mode run the following command:

ts-engine build --node-app --watch

Minifying output

By default the build output is not minified. Terser is used to minify code if you provide the minify option.

To minify the output run the following command:

ts-engine build --node-app --minify

React support

You can build codebases with React and JSX in them.

To support React run the following command:

ts-engine build --node-app --react

Sourcemaps

Sourcemaps are produced for every build regardless whether it is a Node.js application or a library.

Bundling dependencies

Sometimes it is useful to bundle dependencies into the output file so you can run the file without node_modules. This makes it easier to use, share and deploy as it is a single file. You can bundle dependencies into a Node.js application or a library with ts-engine.

ts-engine build --node-app --bundle-dependencies
note

Not all packages can be bundled, ts-engine uses Rollup internally and does not support dynamic calls to require(...) or circular dependencies, as well as other things.

Extending Babel config

Babel config does not need to be provided to ts-engine, however it is possible to extend the config it uses.

Install ts-engine's default babel preset:

yarn add --dev @ts-engine/babel-preset

Add a babel.config.js file in your packages root directory:

babel.config.json
module.exports = {
presets: ["@ts-engine/babel-preset"],
// your config goes here
};