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,

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

  • run specs through Vitest with the Forger Vite plugin — the route for projects on the esbuild-based builders (@angular/build:karma/unit-test), which run no transformers and accept no webpack patch; see Integration with Vitest.

What to check when create throws the "transformer was not applied" error

  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.

  4. The target is not an esbuild-based builder — those never run the transformer; switch the specs to Vitest with the Vite plugin.

See Caveats for the general checklist.

14 September 2026