Skip to content

fix(compiler): fork the swc type checker with the application's plugins - #3596

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
fadiroot:fix/swc-watch-per-app-plugins
Sep 25, 2026
Merged

kamilmysliwiec merged 1 commit into
nestjs:masterfrom
fadiroot:fix/swc-watch-per-app-plugins

Conversation

@fadiroot

Copy link
Copy Markdown

PR Checklist

PR Type

  • Bugfix

What is the current behavior?

Issue Number: N/A

In watch mode with --type-check, the swc compiler forks forked-type-checker with the root compilerOptions.plugins only:

JSON.stringify(configuration.compilerOptions.plugins ?? []),

In a monorepo an application can declare its own plugins under projects.<app>.compilerOptions.plugins, and the non-watch path already loads them per application through loadPlugins() (which resolves compilerOptions.plugins with getValueOrDefault(..., appName)). So with

{ "projects": { "api": { "compilerOptions": { "plugins": ["@nestjs/swagger"] } } } }

and no root plugins, nest build api --builder swc --type-check generates the swagger metadata, while nest start api --builder swc --type-check --watch prints "Found 0 issues" and generates none. The forked checker places whatever it receives under projects[app], so the application's own plugins are lost for good.

#3589 fixed the same class of problem for sourceRoot in these same fork arguments; the plugins argument one line below was missed.

What is the new behavior?

The plugins are resolved through getValueOrDefault(configuration, 'compilerOptions.plugins', appName), matching the non-watch path and the sourceRoot argument.

The existing "should fork the type checker with the built application source root" spec now declares per-application plugins and asserts they reach the forked checker. It fails on master and passes with this change.

Does this PR introduce a breaking change?

  • No

In watch mode with --type-check, the swc compiler forks the type checker
with the root "compilerOptions.plugins" only. In a monorepo an application
can declare its own plugins under "projects.<app>.compilerOptions.plugins",
and the non-watch path already loads them per application through
loadPlugins(), so `nest build api --builder swc --type-check` generated
the CLI plugin metadata while `nest start api --builder swc --type-check
--watch` reported "Found 0 issues" and generated none.

Resolve the plugins through getValueOrDefault with the application name,
the same way nestjs#3589 did for "sourceRoot" one argument above.
@kamilmysliwiec
kamilmysliwiec merged commit 7e456cd into nestjs:master Sep 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants