8.0.1 • Published 3 years ago

@kirbysayshi/ts-run v8.0.1

Weekly downloads
22
License
MIT
Repository
github
Last release
3 years ago

ts-run

Execute TypeScript using babel-register and zero-config. Uses preset-env to target the currently running version of node, so you don't need to worry about feature support either!

Keep in mind that Babel does not check types, it simply strips them out and transpiles.

This package is targeted towards writing either one-off scripts, or tooling scripts for another project.

Usage

npm install @kirbysayshi/ts-run
# or
yarn add @kirbysayshi/ts-run

Then use node's -r flag:

node -r @kirbysayshi/ts-run ./a-typescript-file.ts

Within an npm / package.json script:

"the-script": "node -r @kirbysayshi/ts-run a-typescript-file.ts"

To get typechecking in your editor, ensure there is a reasonable tsconfig.json file near the files you intend to run, and that the include setting matches those files.

babelrc / babel.config.js

There are some cases where you may wish to use local babelrc or babel.config.js file resolution, which Babel normally does. ts-run, by default, disables this behavior to avoid surprises. To re-enable, use the TS_RUN_BABELRC env variable (for babelrc) or TS_RUN_CONFIGFILE (for babel.config.js):

$ TS_RUN_BABELRC=true node -r @kirbysayshi/ts-run ./a-typescript-file.ts
$ TS_RUN_CONFIGFILE=${PWD}/babel.config.js node -r @kirbysayshi/ts-run ./a-typescript-file.ts

Changelog / Addendum

Previous versions of this utility provided an "npm binary" in the form of ts-run. After many struggles trying to get POSIX signals propagating (as well as Yarn 2+ Plug'N'Play support), I decided it was easier to completely avoid the problem by using node directly.

License

MIT

8.0.1

3 years ago

8.0.0

3 years ago

7.0.0

3 years ago

6.0.4

3 years ago

6.0.3

3 years ago

6.0.2

3 years ago

6.0.1

4 years ago

6.0.0

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.0.0

4 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago