Skip to content

esinx/tswc

 
 

Repository files navigation

tswc

NPM version NPM downloads

Compile your TypeScript with tsconfig.json using swc

Changes

This version of tswc uses os.tmpdir to create files instead of path.cwd.

Install

npm install @esinx/tswc @swc/core -D
# Or Yarn
yarn add @esinx/tswc @swc/core --dev

Usage

Just change swc [...options] to tswc -- [options]. That's it! Your tsconfig.json file will be respected.

For example:

# Transpile one file and emit to stdout.
# swc FILE
tswc -- FILE

# Transpile one file and emit to `output.js`.
# swc FILE -o output.js
tswc -- FILE -o output.js

# Transpile and write output to dir
# swc DIR -d dir
tswc -- DIR -d dir

See more about how to use swc cli.

You can change your build script in "package.json" as:

"build": "tswc -- src -D dist",

Now you can run npm run build to build.

Notice

Only a subgroup of fields of tsconfig is supported currently. This is done with tsconfig-to-swcconfig. This means that some tsc features may be missing when compiling with this.

If you want to know what swc config is exactly used, you can use --debug to inspect:

tswc --debug -- [other options...]

Advanced Options

Options:
  --tsconfig <filename>  the filename of tsconfig (default: tsconfig.json)
  --debug                output the final swc config (default: false)
  -h, --help             Display this message
  -v, --version          Display version number

About

Compile your TypeScript with tsconfig.json using swc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 53.5%
  • TypeScript 44.9%
  • Shell 1.6%