mattpocock / xstate-codegen

A codegen tool for 100% TS type-safety in XState
MIT License
245 stars 12 forks source link

Postinstall watch #60

Closed danielkcz closed 3 years ago

danielkcz commented 3 years ago

This PR builds on top of #59, so I will keep it draft until that one is merged.

Currently recommended --once on postinstall is rather fragile (#51). This PR adds a watcher that will recreate generated files automatically when they disappear.

changeset-bot[bot] commented 3 years ago

⚠️ No Changeset found

Latest commit: 1a09a3117707699d1b1f5afb7844cd6caa4c7eb7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

mattpocock commented 3 years ago

@FredyC Could you add more detail as to why this is needed? I have tested locally and can't immediately see it working. Would love to hear more about your rationale

danielkcz commented 3 years ago

@mattpocock I am not sure what else you need to know. It is basically a proper solution for #51. Instead of having postinstall script with --once, when you have codegen running in watch mode and generated files are deleted, it will write them again.

danielkcz commented 3 years ago

@mattpocock Did new PR #68 as I messed up this one.

Also, I would add I am using this approach in the project for a couple of weeks and it's flawless. Besides remembering I need to have codegen running, I don't need to worry about yarn/npm reinstalls anymore.

mattpocock commented 3 years ago

OK, that's good to know. I tested it briefly locally but it wasn't working entirely as expected. I'll retest #68