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

support NX monorepo #1864

Open
sergeylukin opened this issue Jul 26, 2023 · 4 comments
Open

support NX monorepo #1864

sergeylukin opened this issue Jul 26, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@sergeylukin
Copy link

sergeylukin commented Jul 26, 2023

Is your feature request related to a problem? Please describe.
Running previewjs in a NX monorepo results in "No workspace detected".

Screenshot 2023-07-27 at 2 47 42

Describe the solution you'd like

Make it work for a NX based monorepo.

@sergeylukin sergeylukin added the enhancement New feature or request label Jul 26, 2023
@fwouts
Copy link
Owner

fwouts commented Jul 26, 2023

Please provide an example repository that the bug can be reproduced on.

@sergeylukin
Copy link
Author

@sergeylukin
Copy link
Author

https://github.com/sergeylukin/chapp

sorry, that monorepo actually works ^^^

However, this one (https://github.com/sergeylukin/project-x) results in

Screenshot 2023-07-27 at 2 47 42

@fwouts
Copy link
Owner

fwouts commented Aug 1, 2023

Thanks for the link!

There are two issues here:

  • Preview.js is looking at the closest package.json to the current file/directory, and in this case it finds https://github.com/sergeylukin/project-x/blob/3c3e87dd8b883d7d1dd47f30b07e4ce4a9d0f55d/libs/shared/ui-react/package.json which has no dependencies listed. As a result, it infers that React isn't a dependency, and therefore the workspace (everything under this package.json) isn't compatible.
  • Even if you remove this mostly empty package.json, the top-level package.json doesn't actually include "react" as a dependency. It appears it's an indirect dependency, perhaps through @astrojs/react?

You could solve this by:

  • removing the libs/shared/ui-react/package.json (hopefully it's not actually needed by NX?)
  • adding "react" as an explicit dependency in the root package.json

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

No branches or pull requests

2 participants