Adapt relative paths resolution to tsconfig outDir depth
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").Metorequire("../../../../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
-
npm i -
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
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
@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:
- moving the entire package inside the nest src folder (bad idea)
- adding a path alias in tsconfig that points to the schemas package (also a bad idea)