Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Consuming @xstate/compiled/react in monorepo #47

Open
danielkcz opened this issue Sep 27, 2020 · 7 comments
Open

Consuming @xstate/compiled/react in monorepo #47

danielkcz opened this issue Sep 27, 2020 · 7 comments

Comments

@danielkcz
Copy link

danielkcz commented Sep 27, 2020

image

Here is the minimal repo that shows this problem: https://github.com/FredyC/xstate-codegen-monorepo

yarn install
yarn machinery codegen
yarn web validate

I have no idea why it should be a problem considering @xstate/compiled exists in root node_modules.

@danielkcz
Copy link
Author

danielkcz commented Sep 27, 2020

In the branch use-paths I tried a slightly different approach with path aliases, but the outcome is the same.

Specifically, it means I import from ~machinery/xstate/react and that alias is defined in tsconfig. It also utilizes outDir.

@danielkcz
Copy link
Author

Oh wait, I just noticed that @xstate/compiled has been written to modules/machinery/node_modules instead of a root one. Well, that explains it...

@danielkcz
Copy link
Author

danielkcz commented Sep 27, 2020

I have figured an ugly workaround. In the modules/web/package.json I've added this and it works.

"@xstate/compiled": "file:../machinery/node_modules/@xstate/compiled",

I am not sure how a proper solution should look like.

@danielkcz
Copy link
Author

Well, that wasn't the right workaround either. When I modified that machine it went haywire.

So I ended up moving codegen execution to root. It will correctly output to root node_modules and behaves correctly.

I suppose ultimately it's the right solution and documenting it should be good enough.

@mattpocock
Copy link
Owner

OK, to fix this we should probably add a --cwd flag that allows you to pick the current working directory. This wouldn't be too hard to implement/document. What do you think?

@danielkcz
Copy link
Author

Yea, that could certainly help as well.

@mattpocock
Copy link
Owner

@FredyC Here's a PR which might help with the above:

https://github.com/mattpocock/xstate-codegen/pull/50/files

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

No branches or pull requests

2 participants