jaredpalmer / tsdx

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

(optim/fix): only emit type declarations once #691

Closed agilgur5 closed 4 years ago

agilgur5 commented 4 years ago

Also threw in another TS optimization here with the cacheRoot change that's along the same lines but slightly different of a change.


This is extracted out of #367 's 14b539763ef21, but is a better version in a few ways:

  1. Doesn't have issues with declarationMaps as they've also been set to false. Otherwise would get errors / test failures that you can't have declarationMaps without declarations
    • Better testing around this nowadays revealed this bug
  2. : undefined still overrode some declaration/declarationMap settings, also causing errors / test failures, so changed this to not set either on the first emission
  3. moveTypes() was moved into a then of the asyncro() so that it's still part of the progress estimation.

The bugs this fixed in #367 and by extension #535 should no longer be present anyway since #367 switched/improved to use Rollup's code-splitting instead of a separate build & bundle per entry and #535 will need to be updated to use the same output.entryFileNames as a later version of #367 used instead of using separate format dirs.


I also realized that this might fix the bugs with moveTypes() that gave us so many CI issues prior to #504 very recently in https://github.com/jaredpalmer/tsdx/pull/500#issuecomment-605530750. And indeed this does fix those bugs, hence the removals of the error throwaways and a change in the deprecation message by a bit (it's still a problematic option, with another caveat other than those listed that moveTypes() doesn't apply to custom declarationDirs, though that could be fixed). I tested that this was the case by changing rootDir to ./ in every test fixture and running tests a couple of times and no errors were thrown anymore!


The cacheRoot optimization is also related to #328 / #329. And might make #618 obsolete.

agilgur5 commented 4 years ago

Ah, also should note that from my local test runs, the time it took to run all tests decreased by 10-15%, which is a substantial perf improvement! If this tiny change was so substantial, switching to per-ouput plugins is really going to be big when building multiple output formats 😮