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

fix: ignore import path transformations on win32 platform #570

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

pradiev
Copy link
Contributor

@pradiev pradiev commented Aug 3, 2023

The current version of the library throws me a bunch of errors, when trying to build my nest application with transformer-plugin enabled.

In general, the plugin works fine when DTOs are simple enough. But in cases, when classes have complex properties represented by other classes defined elsewhere. In such cases, the application doesn't start as the plugin breaks all such imports

Errors state, that:

ERROR in ../../libs/shared/src/models/dto/user.dto.ts 29:41-155
Module not found: Error: Can't resolve '../H:\projects\myproject\libs\shared\src\models\dto\client-user.dto' in 'H:\projects\myproject\libs\shared\src\models\dto'
****

Which means, it replaces the short relative path (originally import { ClientDto } from './client.dto';) with a long absolute path starting with ../.

Don't know, why you use path.posix.relative and not just path.relative, but however, for the best compatibility possible, I made the if statement to skip all these path transformations when running on a windows environment.

Briefly tested on one of my projects, and this little change fixed me 75 errors, and none of the mappings broke.

P.S. The second commit was created only to pass the sonar verification. Didn't change it to the recommended '??' for backward compatibility, as I'm not ready to properly test the related functionality

P.S.S. @nartc appreciate if you check and merge it ASAP as I really like your package architecturally wise, but it's the only thing that blocks me from running some of my projects natively on my windows laptop.

@sonarcloud
Copy link

sonarcloud bot commented Aug 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

Leeron2010 added a commit to Leeron2010/mapper-js that referenced this pull request Oct 26, 2023
@nartc nartc merged commit 4089bb4 into nartc:main Jan 22, 2024
1 check passed
nartc pushed a commit to jersmart/automapper-typescript that referenced this pull request Jan 22, 2024
* fix: ignore import path transformations on win32 platform

* fix: fixed a "code smell" to pass the code analysis
v-beltran added a commit to v-beltran/mapper-js that referenced this pull request May 10, 2024
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

Successfully merging this pull request may close these issues.

2 participants