Closed MagnusBrzenk closed 3 years ago
Based on the logs, sounds like a duplicate of #888. (EDIT: I've now marked that issue as duplicative of this issue because this one has more details now.) Per my response there:
Looks like this is a cache bug upstream that was recently fixed: https://github.com/ezolenko/rollup-plugin-typescript2/pull/243
Per comments there, you can workaround this by deleting the cache. I don't think you need to fully nuke node_modules
, think you can just delete node_modules/.cache/rollup-plugin-typescript2/
After trying different combinations, I discerned that 'umd' is incompatible with 'cjs'.
That's an interesting find though upstream in rollup-plugin-typescript2
it has no knowledge of format (I've worked on that codebase several times now), so more likely it's some bad hash and race condition that happens during updating
The documentation gives the impression that you can build all three targets simultaneously
You can, a central piece of TSDX and even Rollup itself, and there are tests for this too. You just appear to have hit a transient cache bug upstream, which the logs point to.
So I tried a few things and confirmed the umd
+ cjs
issue. I also confirmed it was happening with system
+ cjs
. But not esm
+ cjs
for some reason. I also tried ordering it differently, but that didn't change anything (they are parallelized in any case but π€· ). I also confirmed umd
+ system
had the issue as well.
The system
addition is interesting, as that shouldn't have much difference from the others aside from format
. system
+ umd
also knocks the suggestion that it's some cjs
issue out π π
Additionally confirmed that this issue did exist in TSDX v0.13.3, but only for the cjs
+ system
combo, which is much less frequent. Was confused that it hadn't happened with v0.13.3 despite it using the same version of rpts2 as v0.14.0, but this allays some of that. And also makes it seem more of a hashing bug or race condition upstream than a specific format, which would've been confusing too given the lack of knowledge of format.
Hmmm v0.13.2, v0.13.1, v0.13.0, and v0.12 don't have this issue π€ That being said, I'm not sure I'd call this a regression per se, because, per my investigation in #896 and https://github.com/ezolenko/rollup-plugin-typescript2/pull/243, that section of code upstream has been like that for a long time. But TSDX's cache directories and Rollup config (which impacts the hash) have changed over time. π€
Side note: the perf decrease when downgrading was noticeable, so that confirms the more recent optimizations I've made help in a variety of codebase sizes π
v0.13.3 consolidated the cache directories for performance reasons (more matching hashes); previously there was a different one for each format, so perhaps that creates more races or makes for an incorrectly matched hash. The problematic cache seems to have an identical hash in all of the logs (only one is different from the rest) π€
This has been fixed with #896 / https://github.com/ezolenko/rollup-plugin-typescript2/pull/243 and just released in v0.14.1.
Still waiting for a response upstream to understand root cause however.
Current Behavior
Right out of the box, running
tsdx build --format umd,cjs,esm
causes following error:After trying different combinations, I discerned that 'umd' is incompatible with 'cjs'.
Expected behavior
The documentation gives the impression that you can build all three targets simultaneously by running
tsdx build --format umd,cjs,esm
. If this is not possible to build both 'umd' and 'cjs' types at once then clarify this is in the documentation; otherwise you have a bug here.Suggested solution(s)
Fix either documentation or underlying problem.
Additional context
Your environment