Write TypeScript packages with optionally zero configuration. Build, lint, start, test and typecheck without any configuration. Whilst ts-engine works out the box without any configuration it is open to extension. You can provide custom Babel, ESLint and Jest configuration.
Checkout the official docs over at https://ts-engine.dev.
yarn add --dev @ts-engine/cli
# Display versionts-engine --version# Display helpts-engine --help# Run a commandts-engine <command> <options>
The entry point of the package is always
Building Node.js applications
When building a Node.js application all code and dependencies are built into a single file.
The output from this build is
# Buildts-engine build --node-app# Build and watchts-engine build --node-app --watch
The outputs from this build are
dist/main.esm.js. This means the built library supports both Common JS and ES Modules when being consumed.
# Buildts-engine build --library# Build and watchts-engine build --library --watch
Typecheck post build
You can tell ts-engine to typecheck once a build has completed automatically.
# typecheck onlyts-engine build --node-app --typecheck# typecheck and emit typests-engine build --library --typecheck --emit
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.
# Node.js applicationts-engine build --node-app --bundle-dependencies# Libraryts-engine build --library --bundle-dependencies
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
The default babel config can be extended by proving a
babel.config.js file in the package folder.
To extend the default babel config see ts-engines's babel preset.
To support React see ts-engines's babel preset.
Code is typechecked using TypeScript.
# Check types onlyts-engine typecheck# Check types and emit type declaration filests-engine typecheck --emit# Watch for changests-engine typecheck --watchts-engine typecheck --emit --watch
Code is linted using ESLint.
For IDE support and to see how to extend ESLint config see ts-engines's lint config.
# Lint codets-engine lint# Lint code and automatically fix fixable issuests-engine lint --fix
Build and immediately run Node.js applications. This speeds up developer workflow as you don't need to manually stop and rerun your application after builds.
# Build and run Node.js applicationts-engine start# Build and run Node.js application on changests-engine start --watch
Bundling dependencies is supported just like in the
# Build and run Node.js applicationts-engine start --bundle-dependencies# Build and run Node.js application on changests-engine start --watch --bundle-dependencies
Forward arguments onto the application using the
# The options "--one --two three" will be forward onto the Node.js applicationts-engine start --watch --args --one --two three
Typechecking post build is supported just like in the
ts-engine start --typecheck
Unit tests are run using Jest.
The default jest config can be extended by using a standard
jest.config.js file. Updating the
transform option may lead to compilation issues when running tests.
You can create a setup file called
jest.setup.ts and it will automatically be picked up and ran.
# Run tests oncets-engine test# All args EXCEPT for --config are forward onto jestts-engine test <jest_cli_args>
Create new Node.js application and library packages using the following command.
# Create Node.js application packagets-engine new-package --node-app --name my-app# Create a library packagets-engine new-package --library --name my-library
First class React support
React is supported as a first class citizen with zero configuration required via the
# Compile React codets-engine build --library --reactts-engine build --node-app --reactts-engine start --react# Lint React code, applies best practice React linting# as well as adding a11y lintingts-engine lint --react# Test react codets-engine test --react# Create new React packagests-engine new-package --library --react --name my-react-libts-engine new-package --node-app --react --name my-react-app
Example package setup
Minimal Node.js application package:
// package.json// src/main.tsconsole.log"Hello world!";
Minimal library package:
When building a library package ts-engine will check and enfore that
types are set correctly in the package file, the build command will not complete a build until they are.
// package.json// src/main.ts;