nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.91k stars 7.55k forks source link

Trouble with webpack with openapi when build an application #9129

Closed ccalderon9411 closed 2 years ago

ccalderon9411 commented 2 years ago

Is there an existing issue for this?

Current behavior

I am building a nestjs application using webpack, but it build, the schemas of DTO´s breaks.

Application in dev image

Application build (schemas breaks) image

Minimum reproduction code

https://github.com/rudemex/nestjs-starter.git

Steps to reproduce

  1. git clone https://github.com/rudemex/nestjs-starter.git
  2. npm install
  3. npm run build
  4. run compiled application
  5. can see the demo of project here: https://rudemex-nestjs-starter.herokuapp.com/docs/

Expected behavior

Schemas names should be as I define in code. image

Package

Other package

@nestjs/swagger @nestjs/class-transformer @nestjs/class-validator class-transformer

NestJS version

8.2.6

Packages versions

"@nestjs/swagger": "^5.1.5",
"@nestjs/class-transformer": "^0.4.0",
"@nestjs/class-validator": "^0.13.3",
 "class-transformer": "^0.5.1"

Node.js version

14.17.0

In which operating systems have you tested?

Other

No response

jmcdo29 commented 2 years ago

This is expected because you are minimizing the code. By doing so, webpack changes the names of the classes, and the metadata read at runtime reflects those names. If you don't really need minimization (there isn't much need for it on the server side) then I'd suggest not using it

rudemex commented 2 years ago

Hi @jmcdo29 Is there any configuration for webpack that transpiles the code in a single file? similar to monorepo but for applications.

jmcdo29 commented 2 years ago

Just using nest build --webpack should do that automatically.

rudemex commented 2 years ago

@jmcdo29 Great, and does it detect if the transpiling is for production? or do you have to expand the configuration?

jmcdo29 commented 2 years ago

@rudemex Please use our Discord channel (Support). We are using GitHub to track Bug Reports, Feature Requests, and Regressions.