strict mode & webpack

Two settings that shape boot-time behavior: one for CI, the other about an architectural limitation.

strict: true

Pass { strict: true } to forRoot() so the app throws on startup when any controller with @WithDocs() has no companion file. Recommended for CI, where failing fast is preferable to a silently incomplete OpenAPI document.

ts
DocfyModule.forRoot({ strict: true });

webpack: true

Architectural limitation

If your nest-cli.json has "webpack": true under compilerOptions, nestjs-docfy will not work, and there is no configuration that makes it work. This is architectural, not a bug to work around, and it has two causes:

First, webpack bundles every module into a single bundle file and never populates Node's require.cache with one entry per original source file, which is what the discovery mechanism depends on. You'll see Could not locate source file for X for every controller with @WithDocs().

Second, even working around that lookup, there's a second, unavoidable barrier: a docs file loaded via require() from outside the bundle creates a class object structurally different from the one the running application actually uses internally. Decorating that isolated copy has no effect whatsoever on the document that SwaggerModule.createDocument() actually serves, and this happens silently, with no error.

Two options: