Skip to content

[Feature]: Add an option to automatically generate exports fields in package.json #1291

Description

@Karibash

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions