Forger Help

Integration with Angular

Angular builds and tests compile through the Angular compiler plugin, not plain tsc. Forger ships a ready-made Webpack patch that injects tsconfig-declared transformers into the Angular compilation.

How it works

Forger's bundled webpack.config hooks the AngularWebpackPlugin and prepends every transformer declared in compilerOptions.plugins to the plugin's before transformer chain. So the single source of truth is your tsconfig*.json:

{ "compilerOptions": { "plugins": [ { "transform": "@artstesh/forger/lib/utils/transformer" } ] } }

1. Install dependencies

npm install --save-dev @artstesh/forger ts-patch

2. Register the webpack config

Point the Angular builder at Forger's shipped config through the webpackConfig option — in angular.json for the affected targets:

{ "projects": { "your-app": { "architect": { "build": { "options": { "webpackConfig": "@artstesh/forger/lib/webpack.config" } } } } } }

Apply the same override to every target that must forge: build, test (Karma), and, if specs are compiled there, serve.

3. Spec files

For spec compilation, either:

  • run tests through Jest with ts-jest — the recommended Angular setup for Forger; follow Integration with Jest, or

  • keep Karma/Webpack and let the webpack patch above transform the specs as part of the bundle.

What to check when it "returns undefined"

  1. The plugins entry is in the tsconfig that the affected target actually uses (tsconfig.app.json/tsconfig.spec.json — they extend different bases).

  2. The webpackConfig override is present on the target being executed.

  3. ts-patch is installed — the Angular plugin path resolves the transformer itself, but ts-patch keeps compiler behavior consistent across build flavors.

See Caveats for the general checklist.

08 September 2026