Transform single files

Turn one source through stdin into stdout.

#

guchho transform reads one input from standard input and writes the result to standard output. It is the command-line form of the programmatic transform API: a loader, a target and the usual options, with no entry points and no file system walking.

guchho transform --loader=ts < src/index.ts > dist/index.js

Tell it how to read the input with a loader and how far back to compile with a target:

guchho transform --loader=jsx --jsx=automatic < src/view.jsx
guchho transform --loader=ts --target=es2020 --minify < src/index.ts

For a TypeScript file whose settings live in a project, point at the config so paths and compiler options are read from it:

guchho transform --loader=ts --tsconfig=tsconfig.json < src/index.ts

When to reach for it

#
  • Compile one file in a pipeline of your own.
  • Check what the compiler does to a snippet without setting up a build.
  • Feed generated source in without writing a temporary file.

Because it reads stdin and writes stdout, it composes: pipe it, redirect it, or embed it in a shell script.

See also

#

Edit this page on GitHub