jaredpalmer / tsdx

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

tsdx build only if `src/` is ahead of `dist/` #1157

Open doliG opened 1 year ago

doliG commented 1 year ago

Current Behavior

I'm using tsdx alongside a next.js app in a monorepo (managed with yarn workspace). My folder structure is:

packages/
  frontend/  # nextjs app
  library/   # tsdx lib used by next js (and others)
  # ... other packages

Managing lib in yarn is very simple, I just added @my-workspace/library in frontend/package.json and yarn is handling the rest.

I have a "prestart" and "prebuild" hook on my frontend package so, each time I run it, tsdx library is fully rebuilt. This is annoying cause the lib build is 10-15x slower than frontend.

We don't want to commit the build of the lib because we think it's not a good practice (tell me if we're wrong).

Suggested Solution

So the ideal solution could be to add an option on tsdx build to rebuild only if src/ has changed since last built in dist/, or use incremental build.

Who does this impact? Who is this for?

For all ppl using tsdx in a monorepo where their lib is a required deps of other packages

Describe alternatives you've considered

Askl lib maintainer (hello @brozorec) to commit dist/ when they change the lib.

Thank you ❤️