statelyai / xstate-tools

Public monorepo for XState tooling
183 stars 36 forks source link

Cannot load a machine inside a file which contains decorator syntax #21

Open BrunoUY opened 2 years ago

BrunoUY commented 2 years ago

Hi, I can´t open a machine defined inside a .tsx file; it's possible?

I'm using stencilJS and the components get the .tsx extension

thanks!

mattpocock commented 2 years ago

Could you make a reproduction? I can load them from within .tsx files fine locally. What version are you on?

BrunoUY commented 2 years ago

Hi, I uploaded it here

https://github.com/BrunoUY/test-xstate-visualizer

I'm trying to open it in https://github.com/BrunoUY/test-xstate-visualizer/blob/master/src/components/app-payment-form/app-payment-form.tsx

line 5

as the "open inspector" text don´t appear I used the command "XState: open inspector" and I got the message "could not find a machine at the current cursor"

I put another machine on https://github.com/BrunoUY/test-xstate-visualizer/blob/master/src/helpers/promise-machine.ts and this one got the "open inspector" button on the editor without a problem

mattpocock commented 2 years ago

Thanks - looks legit, I tested it and it fails. It looks like it doesn't like the decorator syntax used there, which is annoying because I've fixed that before.

For now, define your machine in a separate file to the decorator syntax and it'll work.

viglucci commented 1 year ago

Adding an additional data point where I just had the same issue inside a nestjs project where decorators are common. Had to comment out the decorators for the extension to identify the machine.