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

[Bug] replaceImportPath incorrectly determines import paths from external modules #1411

Closed
IodizedGabe opened this issue Jun 29, 2021 · 2 comments

Comments

@IodizedGabe
Copy link
Contributor

IodizedGabe commented Jun 29, 2021

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

Using an enum from a separate module for a DTO class field results in the transpiled code under the _OPENAPI_METADATA_FACTORY property to be incorrect.

Screen Shot 2021-06-29 at 11 33 07 AM

Expected behavior

Previously, in 4.8.0, this would reference the expected import path starting from node_modules.

Screen Shot 2021-06-29 at 11 32 36 AM 1

This appears to have been introduced in: #1318. Previously, this logic would fall into the else block and have its import path be determined that way. Because the path here is technically resolvable, it doesn't raise an error and gets saved as-is.

Minimal reproduction of the problem with instructions

Example minimal repo: https://github.com/IodizedGabe/nestjs-swagger-incorrect-import

Steps:

  1. Run yarn build
  2. Open dist/scope.dto.js

The enum field will reference the local path to a given module, and not the expected import path.

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

I would like to continue using enums from shared packages across my services.

Environment


Nest version: 

        "@nestjs/common": "7.6.18",
        "@nestjs/config": "0.6.3",
        "@nestjs/core": "7.6.18",
        "@nestjs/passport": "7.1.5",
        "@nestjs/swagger": "4.8.1",
 
For Tooling issues:
- Node version: v12.20.2 
- Platform:  Mac/Linux

Others:

"typescript": "4.3.4",
@kamilmysliwiec
Copy link
Member

Fixed in 4.8.2

@IodizedGabe
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants