rspack
rspack copied to clipboard
[Bug]: `@nestjs/swagger` plugin not working when using rspack in Nx+NestJS
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
- Run
pnpm install. - Run
nx serve service. - Open
http://localhost:3000/apiin browser and scroll to the bottom. - Expand CreateUserDto to check webpack generated entity definitions.
It should display properties like this:
- Goto
apps/service/package.jsonline 11. - Replace
webpack-cliwithrspackand rerunnx serve service. - Repeat step 3 & 4.
The properties are all gone:
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.