Skip to content
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

compiler: don't extract common exports #798

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

josephjclark
Copy link
Collaborator

@josephjclark josephjclark commented Oct 18, 2024

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 export fn, 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 and adaptor.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!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

@josephjclark josephjclark changed the base branch from main to release/collections October 18, 2024 09:00
@josephjclark josephjclark marked this pull request as ready for review October 18, 2024 11:01
@josephjclark josephjclark merged commit 71edb8b into release/collections Oct 22, 2024
6 checks passed
@josephjclark josephjclark deleted the better-compiler-exports branch October 22, 2024 10:40
@josephjclark josephjclark mentioned this pull request Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant