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

Implement subpath exports #73

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

colinhacks
Copy link

@colinhacks colinhacks commented Jul 17, 2024

This implements support for wildcards in "exports".

  • All tests are passing, including a quite robust one I added to builds/package-exports.ts
  • Each ExportEntry can now potentially be mapped to multiple SourcePath objects. When an asterisk is detected in the outputPath, this uses glob to find all src files that match against the wildcard path (it runs a glob search for every distExtension in tryExtensions).
  • There's virtually no functional changes to getExportEntries, I just cleaned up the parseExportsMap recursion logic a bit.
  • My approach required passing an additional parameter into parseExportsMap. This method was accumulating a lot of parameters (it was up to four) so I merged them into a params object instead. I can flatten this out again if you prefer. The new interface I added is called ParseExportsContext.
  • I changed fsExists to be synchronous and use existsSync (which isn't deprecated, unlike exists). For a CLI tool like this it's usually faster to keep things synchronous anyway, since Promises are just adding overhead and additional ticks. I can change this back too if you prefer.

I couldn't find a way to format the files according to a standard config, am I missing something?

@colinhacks colinhacks marked this pull request as ready for review July 17, 2024 04:45
@privatenumber
Copy link
Owner

privatenumber commented Jul 19, 2024

Thanks for the PR Colin!

You can lint & auto-fix via pnpm lint --fix (I need to make a contrib guide)

  • I changed fsExists to be synchronous and use existsSync (which isn't deprecated, unlike exists). For a CLI tool like this it's usually faster to keep things synchronous anyway, since Promises are just adding overhead and additional ticks. I can change this back too if you prefer.

I'm open to this change, but given the motivation is performance, I think I'd want it in a separate PR addressing & evaluating async/sync performance holistically. Do you mind separating it out?

@privatenumber privatenumber linked an issue Jul 19, 2024 that may be closed by this pull request
@colinhacks
Copy link
Author

colinhacks commented Jul 19, 2024

I'm open to this change, but given the motivation is performance, I think I'd want it in a separate PR addressing & evaluating async/sync performance holistically. Do you mind separating it out?

Done! Motivation is both performance and DX...trying to get flatMap and async to play nice was not fun lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for subpath patterns
2 participants