swagger icon indicating copy to clipboard operation
swagger copied to clipboard

Adapt relative paths resolution to tsconfig outDir depth

Open mgrisole opened this issue 2 years ago • 8 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

This issue is almost a duplicate of https://github.com/nestjs/swagger/issues/2114, I can't figure out why this should be address in Discord since it is a real bug and we are facing exactly the same issue in a pnpm workspace.

I can get it working by performing this manual change on dist:

  • Open apps/nest/dist/src/app.controller.js
  • Change require("../../../packages/math-helpers/dist/index").Me to require("../../../../packages/math-helpers/dist/index").Me

Possible related issues: https://github.com/nestjs/swagger/issues/1386 https://github.com/nestjs/swagger/issues/501

Minimum reproduction code

https://github.com/bindermuehle/monorepo-issue

Steps to reproduce

  1. npm i
  2. npm run start:dev -w nest

Expected behavior

nest/swagger should correctly resolve the paths

Package version

7.1.10

NestJS version

9.0.0

Node.js version

20.9.0

In which operating systems have you tested?

  • [X] macOS
  • [ ] Windows
  • [ ] Linux

Other

No response

mgrisole avatar Nov 14 '23 09:11 mgrisole

Removing one of these two statements fixes the issue, but I fail to understand the whole context at the moment: https://github.com/nestjs/swagger/blob/c4cbca6b6e7cc531132214e8dfd4654377e9447f/lib/plugin/utils/plugin-utils.ts#L153-L155 https://github.com/nestjs/swagger/blob/c4cbca6b6e7cc531132214e8dfd4654377e9447f/lib/plugin/utils/plugin-utils.ts#L192

mgrisole avatar Nov 14 '23 15:11 mgrisole

@kamilmysliwiec We're also facing this issue.

We have a schemas package that's used in our frontends and backends.

Until this is fixed, our only options are:

  1. moving the entire package inside the nest src folder (bad idea)
  2. adding a path alias in tsconfig that points to the schemas package (also a bad idea)

aqeelat avatar Jul 22 '24 08:07 aqeelat