jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.28k stars 507 forks source link

Hot-reloading React package with CRA #686

Closed dfsa-bot closed 4 years ago

dfsa-bot commented 4 years ago

I want to develop a standalone react component, let's call it Test, so any CRA app could just add it as npm dependency and then use it directly like: <Test{...props} />. I am having difficulties with local development of the component - is there any way to have local server with hot reloading up and running? I tried tsdx start running in one terminal window, then in the second window an instance of create-react-app's yarn start. It kind of worked - manual page refresh is required. Any tips?

agilgur5 commented 4 years ago

So the templates use Parcel, not CRA, but I'm not sure why they wouldn't work the same.

I don't use this multi-build myself too often, so I'm not a great resource on this, but something you might want to try that's popped up a couple of times for various forms of multi-builds is the --noClean flag.

578 mentions CRA in particular and how the current naive method of cleaning can cause watch issues, so --noClean is a workaround for it until a more intelligent clean solution exists for Rollup