xstate-tools icon indicating copy to clipboard operation
xstate-tools copied to clipboard

Bug: VSCode visualizer doesn't resolve imported variables

Open adrianbw opened this issue 10 months ago • 3 comments

When a state chart includes imported values, the visualizer doesn't seem to be resolving them, which makes the visualizer fail. This makes it really hard to share code across the various parts of our system. Given that the visualizer is a huge selling point, this is probably going to make me recommend not using xstate.

Here's without imports: without-imports

And with: with-imports

I've created a reproduction of this issue here: https://github.com/adrianbw/xstate-vscode-import-problem.

adrianbw avatar Mar 29 '24 18:03 adrianbw

I'd be happy to try helping with this, but I'm having trouble getting the repo working with VSCode. If there are directions for that somewhere, I'd appreciate it.

adrianbw avatar Mar 29 '24 18:03 adrianbw

@davidkpiano this is actually a serious problem. I also prefer to keep my states as enums and action types outside of the state description to not bloat the state file. I guess this might be related to how the Stately.ai online editor works - it also expect all the variables defined in one file. But this limitation in VS Code makes it unusable for large projects.

I was going to adapt XState library and showcase the cool state charts to my team but now I can't do it without breaching our code organization guidelines.

nikuz avatar Jul 04 '24 02:07 nikuz

I have the same issue in our project. I tried to import the states definition from an external file and it did not work. But if states are defined in the demo file inline it works great. The sample project @adrianbw has perfectly sums up the problem.

sparachi avatar Jul 22 '24 18:07 sparachi