compiler: don't extract common exports #798
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short Description
There's a very gnarly bit of compiler code called
preloadAdaptorExports
which tries to work out the list of valid exports from an adaptor.We've had a lot of trouble around this historically - it doesn't actually work terrible well, and relies on some ropey, poorly tested code in
describe-adaptor
The problem right now is that the list of exports for an adaptor is very generous. We basically list every export listed in the d.ts (regardless of how or where it's exported). And for some reason we also list everything exported from common, regardless of whether it's actually exported from the adaptor. Frankly I forget what this is all about.
Now this is a problem when we have multiple adaptors, a la collections, because the compiler things that both
http
and collections exportfn
, so it'll try to import it from both packages. Resulting in all kinds of trouble.My solution is the lowest effort, lowest risk thing I can see: only work out the exports for
index.d.ts
andadaptor.ts
, because those two files are all that really matter for job code.Now we're cheating a bit on the adaptors.d.ts thing, it's not a generic solution and makes an assumption about adaptor structure. But it's a fair one. And working out the exports properly, even with typescript, is actually really hard.
One day, when we re-write
describe-package
, we'll have a much more robust and generic solution for this sort of thing. But for now, I'll settle for this.AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy