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

No way to enforce JavaScript and type exports for all defined package exports #5252

Open
mcmire opened this issue Jan 31, 2025 · 0 comments
Open

Comments

@mcmire
Copy link
Contributor

mcmire commented Jan 31, 2025

It is important that we can see at a glance all of the exports that a package has (both JavaScript and TypeScript exports) and that we can also easily spot changes to the exports in PRs.

Currently for some packages we have an index.test.ts which tells us which JavaScript exports that package has. However, we don't have similar tests for TypeScript exports, so we don't have visibility into those at all. Also, we only tend to write tests for the primary export (.) but if we decide to add custom subpath exports for packages in the future we'd have to remember to add tests for those.

It would be good if we had a way to automatically find all of the exports for a package, taking subpath exports into consideration, and then assert the correct list, all in one go.

Having better tests around exports means that we would no longer need to enforce that packages use explicit exports; they could go back to using export * instead. (See #5224 for the PR that prompted this ticket.)

Acceptance Criteria

  • Each package has a file exports.test.ts which asserts all JavaScript and TypeScript exports for that package, for all defined paths in the package manifest's exports field.
  • Under the hood this uses a custom matcher and function which iterates through the defined exports in that package's manifest and discovers all of the exports which that package has.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant