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: properly resolve file path in nx workspace #16

Merged

Conversation

dmitry-stepanenko
Copy link
Contributor

In Nx workspaces applications live under the nested dir (e.g. apps/myapp). Looks like the path resolution is broken in this case, specifically at this line

return `import "${rootRelativeId}";`
. rootRelativeId there is relative to project root, not workspace, thus the import statement points to an invalid file

To reproduce:

  1. run npx create-nx-workspace@latest --preset=qwik-nx
  2. install vanilla extract in the same way it's added to regular qwik project: add vanilla extract dependencies to package.json, plugin to the vite config and a sample route that uses it
  3. notice the error

@wmertens
Copy link
Owner

wmertens commented May 6, 2023

Thank you, I'll take a look shortly!

I also saw you writing that qwik add is broken for NX, do you know why?

@dmitry-stepanenko
Copy link
Contributor Author

dmitry-stepanenko commented May 6, 2023

@wmertens it's not broken, it's just incompatible, as qwik cli can only work with the standard workspace layout with 1 app.

qwik-nx recreates some of the integrations, more to come 🙂

@wmertens wmertens merged commit b2e01f9 into wmertens:main Jun 6, 2023
3 checks passed
@wmertens
Copy link
Owner

wmertens commented Jun 6, 2023

Thanks!

@wmertens
Copy link
Owner

wmertens commented Jun 7, 2023

@dmitry-stepanenko actually, can you walk me through what happens? So a single Vite is running across multiple workspaces?
What I don't understand is that you now import relative paths, no matter where the file is in the tree, so that might cause issues. Why doesn't it work with the absolute paths?

Ah nevermind I get it, the imports in nx need to include the workspace, right? And the relative paths are needed to maintain consistent content hashes across machines

@dmitry-stepanenko
Copy link
Contributor Author

@wmertens prior to this commit it would create paths to files assuming the project and repository roots are the same (e.g. src/file.css, which is resolved as /Users/dmitriy/myproj/src/file.css later).

This does not work for monorepos because particular project lives at nested folder like apps/myapp. With that in place when it generates path src/file.css, it will still be resolved as /Users/dmitriy/myproj/src/file.css, while it should actually be /Users/dmitriy/myproj/apps/myapp/src/file.css

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.

None yet

2 participants