rspack icon indicating copy to clipboard operation
rspack copied to clipboard

[Bug]: `@nestjs/swagger` plugin not working when using rspack in Nx+NestJS

Open Liranius opened this issue 1 month ago • 1 comments

System Info

System:
  OS: Windows 11 10.0.26100
  CPU: (24) x64 12th Gen Intel(R) Core(TM) i9-12900HX
  Memory: 37.29 GB / 63.77 GB
Binaries:
  Node: 22.19.0 - C:\Program Files\nodejs\node.EXE
  npm: 10.9.3 - C:\Program Files\nodejs\npm.CMD
  pnpm: 10.15.0 - C:\Program Files\nodejs\pnpm.CMD
Browsers:
  Chrome: 140.0.7339.208
  Edge: Chromium (140.0.3485.54)
  Internet Explorer: 11.0.26100.1882
npmPackages:
  @rspack/cli: ^1.5.8 => 1.5.8 
  @rspack/core: ^1.5.8 => 1.5.8 

Details

@nestjs/swagger plugin can be used to generate entity property definitions for swagger doc in NestJS. With it being enabled the developer no longer has to add ApiProperty decorators manually.

By default NestJS use webpack as bundler and the plugin works just fine.

However, when replace webpack with rspack, the plugin no longer be able to process entity class properties automatically.

Reproduce link

https://github.com/Liranius/nx-test

Reproduce Steps

  1. Run pnpm install.
  2. Run nx serve service.
  3. Open http://localhost:3000/api in browser and scroll to the bottom.
  4. Expand CreateUserDto to check webpack generated entity definitions.

It should display properties like this:

Image

  1. Goto apps/service/package.json line 11.
  2. Replace webpack-cli with rspack and rerun nx serve service.
  3. Repeat step 3 & 4.

The properties are all gone:

Image

Liranius avatar Oct 13 '25 11:10 Liranius

Seems the _OPENAPI_METADATA_FACTORY of CreateUserDto is missing. It is injected by swagger plugin but I can not figure out how it is done. I I'm not familiar with the swagger plugin and may need some help.

LingyuCoder avatar Nov 14 '25 06:11 LingyuCoder