-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache not invalidating declarations when import changes (need to use clean: true
)
#292
Comments
clean: true
)
It's possible there's a cache bug here, potentially with how the tree is calculated (e.g. it didn't recognize that The other thing I noticed that could be related is that your Rollup config has |
investigated cache invalidationAs I've investigated more issues in this codebase and solved the majority of them, I kept coming back to this and was curious as to how this could happen. Especially as this isn't related to type-only files (#7).
the problem is with declarations specifically
Reading this again, I think I've found the bug. The cache invalidation check has a flag, Notably, this flag is set to This seems to be because the JS code output shouldn't change if an import changes. That, I believe, is accurate. That's one of the reasons why Babel can just transpile TS code per-file (whereas type-checking requires knowledge of the whole "Program", i.e. the whole module graph). But compilation also creates the declaration for the file (if one exists), and the declaration has types in it -- and so needs knowledge (and invalidation) of the module graph to be correctly output. bug, solving has perf impact 😕So this is a bug, and unfortunately, solving it will have a performance impact. We can limit that impact by only invalidating if not hit often?I was surprised this hasn't been hit often, but the use-case is a bit of an edge-case. When developing, one is often not using the declaration output. That also just makes it hard to detect too -- it might actually be more frequent of an issue that just hasn't been found too much. The declarations typically only matter during publishing, and cleaning a cache prior to publishing is always recommended. Plus, if your CI publishes it, it probably has a fresh build anyway. But this will be particularly noticeable when working on a multi-repo or monorepo set-up, as you might be using the declaration output pretty frequently when switching between repos/individual projects. As those have become more popular, I suspect that's why this bug finally got detected. Thanks for finding this bug and creating a simple example that illustrates it! |
clean: true
)clean: true
)
What happens and why it is wrong
I have a React project with compound componetns. Meaning - I'm using this kind of declaration:
An example of usage:
Now, if I change Child1's signature, for example changing it to expect
prop2
instead ofprop1
and then rebuilding, theChild1.d.ts
file is updated but theParent.d.ts
file isn't. This means that I get exceptions when running the code because it still accepts the oldprop1
.This means I need to run all builds with
clean: true
Versions
rollup.config.js
`rollup.config.js`:
tsconfig.json
`tsconfig.json` :
The text was updated successfully, but these errors were encountered: