nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.82k stars 2.38k forks source link

NestJS Swagger Plugin with Shared Libs #28836

Closed vaskouk closed 3 weeks ago

vaskouk commented 3 weeks ago

Current Behavior

Hello all,

I've created a nest preset which includes api(nest) & dashboard(angular). I am on the latest version of all versions. I am trying to introduce the swagger plugin for my nest api, although when i add to webpack.config.js the plugin transformer:

transformers: [ { name: "@nestjs/swagger/plugin", options: { introspectComments: true } } ]

I got back Module not found: Error: Can't resolve './shared/src/index.ts' and this is because I am importing some specific validators/enums etc from my shared lib like:

import { IsAfterNow, IsDateRangeValid, IsTimestamp } from "@mylib/shared";

What do I miss? Thanks in advance

Expected Behavior

No error when using swagger plugin

GitHub Repo

No response

Steps to Reproduce

  1. Create a nest preset workspace
  2. Add angular, shared lib & a nest app with nx plugin
  3. Install @nestjs/swagger and append swagger plugin to api's webpack config
  4. Create a dto within your api, that imports something from shared lib (like an enum)
  5. Error will popup for module not found

Nx Report

Node : 20.18.0 OS : darwin-arm64 Native Target : aarch64-macos yarn : 1.22.22

nx (global) : 20.0.10 nx : 20.0.11 @nx/js : 20.0.11 @nx/jest : 20.0.11 @nx/eslint : 20.0.11 @nx/workspace : 20.0.11 @nx/angular : 20.0.11 @nx/cypress : 20.0.11 @nx/devkit : 20.0.11 @nx/eslint-plugin : 20.0.11 @nx/nest : 20.0.11 @nx/node : 20.0.11 @nx/web : 20.0.11 @nx/webpack : 20.0.11 typescript : 5.5.4

Registered Plugins: @nx/webpack/plugin @nx/eslint/plugin @nx/jest/plugin @nx/cypress/plugin

Failure Logs

No response

Package Manager Version

yarn: 1.22.22

Operating System

Additional Information

No response

m3Lith commented 2 weeks ago

Well, how did you solve this @vaskouk ?

vaskouk commented 2 weeks ago

@m3Lith It seemed to be an issue within my dto in terms of import paths!