Closed danielkcz closed 3 years ago
@FredyC This is fine as an issue - no worries. Discussions is beta-only, sadly.
I also ran into this, but pushed a version that fixed it for me. 0.1.3 was the version in which I pushed the fix.
Which version are you on?
Ah sorry, a version is 0.2.0, so I guess it's something else in my case?
To be honest, I noticed this behavior of VSCode with graphql-code-generator
as well. Any changes are not refreshed until I open the generated file.
I was only able to google some old VSCode issues https://github.com/Microsoft/vscode/issues/31600 https://github.com/Microsoft/vscode/issues/21252, but nothing useful there.
The long-term plan is to fold xstate-codegen in with a VSCode extension. Once we're integrated with VSCode properly, we'll be able to do things like alert Typescript's language server that a change has occurred in the file.
Until then, let's see if we can at least improve it for you. What OS are you on? This may make a difference. I am on MacOS and not seeing this slowdown any more.
Well, Windows 10, but I would expect it should be fine given it's both Microsoft products 😕
However, I am also using Windows Subsystem for Linux and I am connected to it through remote dev. It's effectively a true Ubuntu running inside Windows with the filesystem and everything. I guess that's a lot of unknowns considering :)
Interesting... It could be a remote VM thing. It's not working on the codesandbox demo I put together:
https://codesandbox.io/s/intelligent-bhaskara-7etw2?file=/src/demo.machine.ts
I'd be interested to keep this issue here and see if others are experiencing the same issue. I thought I'd found a fix (0.1.3) but we should hear if others are seeing the same thing.
WSL2 is not VM based, it's running full Linux kernel in the OS.
Ok, I tried running your example locally within Windows and it's working correctly there. So you are right, it's the remote dev most likely. But I am not giving up WSL for this, because ext4 beats ntfs :)
I guess I will try opening the issue with them tomorrow.
Ah, I fiddled with it more and got interesting discovery.
I've moved compiled
folder from node_modules
into src
and referenced to it relatively in my source code. Then modified the generated index.d.ts
in the external editor and VSCode has refreshed it correctly even within WSL.
Not sure why node_modules
would be a problem in WSL, but not on Windows. But it's a viable workaround if you would allow specifying a path where to write generated files.
I see now that outDir
is already available but for some reason, it did not help. I will investigate more tomorrow.
Looks like I was just impatient. It works with this option, it just takes a 2-3 second in my project, but I have general performance issues with TS, so that's not about codegen.
OK great, I'm glad that outDir works for this use case. Can we close the issue?
I think it would be still interesting to investigate why node_modules
is a problem, but otherwise feel free.
While investigating #47 and after applying "workaround" of moving code generation to root it seems it also solved this issue of lazy refresh. Apparently, VSCode fails to see changes in the subfolder node_modules
. Now it's ok to close this :)
Sorry for the issue, not sure where else to put it (can you enable discussions?).
I don't know what's wrong, but when I do some change to a machine, save it,
xstate-codegen
runs and yet in VSCode I still see a type error. Even when I keep the generated file open in the tab it doesn't refresh. Only after I switch to it and back, the VSCode sees the change, and checks are working fine.I assume it's some settings, but I just don't see anything suspicious here. Did anyone encounter something similar?