No way to enforce JavaScript and type exports for all defined package exports
- Dominant language
- TypeScript
- Stars
- 413
- Forks
- 308
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 253
Description
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 https://github.com/MetaMask/core/pull/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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing existing index.test.ts files and the package manifest exports fields across the monorepo. Determine how a custom matcher and function can iterate over every defined export path and discover both JavaScript and TypeScript exports. Done means each package has an exports.test.ts asserting the complete export list, including subpaths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- developer-experience, testing, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100