Building with ts-patch
Any pipeline that compiles TypeScript through tsc can apply Forger's transformer via ts-patch — Webpack loaders that call tsc, custom build scripts, CI pre-publish steps.
1. Install
2. Declare the transformer
3. Compile with tspc instead of tsc
tspc is a drop-in replacement for the tsc CLI: same arguments, same behavior, plus execution of the declared transformers. The compiled output has every Forger.create<T>() call site rewritten with the injected type description.
Verify the output
After a build, the emitted JavaScript contains the injected argument — a compact JSON tree after the regular arguments:
If the emitted call has no trailing JSON argument, the transformer did not run for that file.
Notes
The transformer path
@artstesh/forger/lib/utils/transformerresolves to the compiled transformer inside the installed package.Consumers building through bundlers with their own TypeScript loaders (ts-loader, fork-ts-checker) should configure the transformer in the loader's
getCustomTransformershook, using the same module — the factory exported from@artstesh/forger/lib/utils/transformeraccepts the program and returns the transformer.