Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong relative require path for custom rootDir #1386

Closed
Kolobok12309 opened this issue Jun 9, 2021 · 4 comments
Closed

Wrong relative require path for custom rootDir #1386

Kolobok12309 opened this issue Jun 9, 2021 · 4 comments

Comments

@Kolobok12309
Copy link

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I have dto with enum field, @root/types example package from this monorepo

import { Role } from '@root/types';
export class InputDto {
  id: number;
  role?: Role;
}

Result dist

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InputDto = void 0;
const openapi = require("@nestjs/swagger");
class InputDto {
    static _OPENAPI_METADATA_FACTORY() {
        return { id: { required: true, type: () => Number }, role: { required: false, enum: require("../../types/dist/users/role.interface").Role } };
    }
}
exports.InputDto = InputDto;

Expected behavior

Expected require path ../../../types/dist/users/role.interface or @root/types/...

Minimal reproduction of the problem with instructions

Repo
To reproduce you can change rootDir to . or mb src/foo

What is the motivation / use case for changing the behavior?

Environment


Nest version: 7.6.15

 
For Tooling issues:
- Node version: v12.14.0
- Platform:  Win 10

Others:

My `rootDir` is `.`
@Kolobok12309
Copy link
Author

Is duplicate of #846

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@Kolobok12309
Copy link
Author

Don't think i can do it without more bug

@Kolobok12309
Copy link
Author

Kolobok12309 commented Jun 12, 2021

It fix my problem, i use yarn workspaces which create symlinks in node_modules and typescript resolve it, mb it will help someone

// tsconfig.json
...
preserveSymlinks: true
...

Core of trouble it symlinks for monorepo

@nestjs nestjs locked and limited conversation to collaborators Jun 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants