web-infra-dev / web-infra-dev/rslib
[Feature]: Add an option to automatically generate exports fields in package.json
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 67
- Avg merge
- 6h 9m
- Merged PRs (30d)
- 57
Description
What problem does this feature solve?
Currently, rslib aims for a zero-configuration experience by treating package.json as the single source of truth (see #62).
However, since rslib does not exclude *.test.ts files by default, it’s difficult to achieve a truly configuration-free setup.
To improve this, it would be helpful to introduce an option that automatically generates the following fields in package.json based on the build entries:
- main
- module
- types
- exports
This would make the build output and package metadata consistent without requiring manual edits to package.json.
For reference, tools like tsdown already provide a similar feature that derives these fields from the build entry configuration.
Implementing something comparable in rslib would simplify the developer experience and reduce maintenance overhead.
What does the proposed API look like?
import { defineConfig } from '@rslib/core'
export default defineConfig({
output: {
exports: true,
},
})
When enabled, rslib automatically generates exports, main, module, and types fields in package.json based on the build entries.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the output configuration and build-entry handling in rslib, then review how package.json is currently treated as the source of truth. Define the generated main, module, types, and exports values for the proposed output.exports option, and verify that the resulting package metadata matches the build entries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100