Skip to content

Add module and exports field to package.json #2858

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

reekystive
Copy link

Description

Add "module" and "exports" fields to package.json to provide better ESM support.

Changes

  • Add "module": "./esm/index.js" field to allow bundlers to use the ES modules version

  • Add "exports" field to provide correct entry points for different import methods:

    • "import": ESM module imports
    • "require": CommonJS imports
    • "types": TypeScript type definitions
  • package.json: Updated the main field to use a relative path, added a module field for ES module entry point, and updated the types field to use a relative path.

  • package.json: Added an exports field to specify different entry points for import, require, and types.

Benefits

  • Improved compatibility with modern bundlers
  • Support for Node.js dual package specification
  • Clearer distinction between ESM and CommonJS entry points
  • Follows modern JavaScript package best practices

Breaking Changes

None, this change is fully backward compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant