Skip to content

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

Open
@mcmire

Description

@mcmire

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions