xstate-codegen
xstate-codegen copied to clipboard
Publishing package with generated types
How would one go about publishing a compiled machine w/ generated types to npm (ie: can be consumed by js or ts)?
I see that there's an --outDir parameter but not obvious how to me how to use this as part of a publish script. The consumer of the package might also have machines (w/ generated types) as well. Basically, curious what the workflow is if you've got your machines distributed across multiple packages.
I think this use case was never thought of. In theory, it could work if you set up postinstall script for your package and let it generate types there.
But it will be a problem in case of multiple packages generating this since all will be writing to @xstate/compiled. You would need to utilize --outDir to have a different output directory per package and import from that within the package instead of @xstate/compiled.
Good to know, makes sense why I got nowhere with this 😅
Feels like this is a use-case that should be pretty streamlined-- I'd definitely be willing to help get it there!