-
Notifications
You must be signed in to change notification settings - Fork 404
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
CLI plugin breaks paths when used with webpack alias (windows) #2661
Comments
We need a reproduction repository to fix this issue |
Sure, here you go: https://github.com/enricobuehler/nestjs-graphql-paths-bug |
Just tested it on macOS, there the issue doesn't occur. |
With the newest version compiling still fails on windows, can i create a pull request with the suggested fix or help otherwise to get this fixed? |
@enricobuehler yes please it would be appreciated. You can also look into #2734 it might be related. |
removed the addition of a '.' suffix so paths are not broken on windows anymore fixes nestjs#2661
I'm running into the same issue on Windows (but it works fine on Linux). The linked pull request fixes the compilation errors on Windows but then breaks things on Linux:
I tried to investigate what's causing the original issue, in order to fix it for Windows without breaking it on Linux, and it seems like the issue is that For example, when this code runs on Windows: graphql/packages/graphql/lib/plugin/utils/plugin-utils.ts Lines 111 to 112 in 4dd5484
Maybe the problem here is using My hacky fix for now is to only prefix the path if it actually is relative: relativePath = !path.isAbsolute(relativePath) && relativePath[0] !== '.' ? './' + relativePath : relativePath; |
Perhaps we should include your hacky fix as a temporary solution to this issue, WDYT? @mikejpeters Would you like to create a PR for this? |
Yeah I can probably give it a shot this weekend if no-one else can do it in the meantime. I would like to try maybe adding some tests for Linux and Windows filepaths as well since it seems easy to fix one but break the other |
Is there an existing issue for this?
Current behavior
The plugin breaks import paths when used in combination with webpack aliases.
It seems to happen because webpack transforms the import paths to absolute paths, which start with the drive letter, e.g.
D:\...
and then the plugin suffixes this path with./
. If really needed i can provide a minimal reproduction but since i know which code is responsible for the bug i thought it wouldn't help.Minimum reproduction code
Steps to reproduce
-> Import fails only for the files modified by the cli
Expected behavior
Obviously the paths shouldn't break, however im not sure how to achieve this. In my case just removing the
./
suffix fixed it, could also provide a PR for this, but don't know about possible side effects. The suffix is added here: https://github.com/nestjs/graphql/blob/master/packages/graphql/lib/plugin/utils/plugin-utils.ts#L112Package version
10.1.6
Graphql version
graphql
: 16.6.0apollo-server-express
: 3.11.1NestJS version
9.2.1
Node.js version
19.6.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: