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

Publishing package with generated types

Open Silverwolf90 opened this issue 4 years ago • 2 comments

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.

Silverwolf90 avatar Nov 16 '20 19:11 Silverwolf90

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.

danielkcz avatar Nov 17 '20 11:11 danielkcz

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!

Silverwolf90 avatar Nov 17 '20 12:11 Silverwolf90