Skip to content

feat: add ESM entry point with named exports#5

Merged
zkochan merged 12 commits intomainfrom
esm-exports
Mar 24, 2026
Merged

feat: add ESM entry point with named exports#5
zkochan merged 12 commits intomainfrom
esm-exports

Conversation

@zkochan
Copy link
Member

@zkochan zkochan commented Mar 24, 2026

Summary

  • Adds index.mjs with proper ESM named exports (TRUSTED_PACKAGE_NAMES, DEFAULT_ALLOW_BUILDS)
  • Adds conditional exports field in package.json so ESM consumers get index.mjs and CJS consumers get index.js
  • Sub-path exports for ./allowBuilds.json, ./allow.json, and ./pnpmfile.cjs
  • Adds ESM test (test-esm.mjs)

This enables pnpm to use import { DEFAULT_ALLOW_BUILDS } from '@pnpm/plugin-trusted-deps' without CJS interop issues.

Test plan

  • CJS tests pass (8/8)
  • ESM tests pass (2/2)

zkochan added 2 commits March 24, 2026 09:13
Add index.mjs with proper named exports (TRUSTED_PACKAGE_NAMES,
DEFAULT_ALLOW_BUILDS) and conditional exports in package.json so
ESM consumers can use named imports directly.
@zkochan zkochan marked this pull request as ready for review March 24, 2026 15:02
@zkochan zkochan requested a review from Copilot March 24, 2026 15:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a first-class ESM entry point for @pnpm/plugin-trusted-deps with named exports and updates package export resolution so ESM/CJS consumers get the appropriate entry file, plus adds an ESM-focused test.

Changes:

  • Added index.mjs to provide ESM named exports (TRUSTED_PACKAGE_NAMES, DEFAULT_ALLOW_BUILDS).
  • Added exports map in package.json for conditional ESM/CJS entry resolution and subpath exports for JSON + pnpmfile.cjs.
  • Added test-esm.mjs and extended the test script to run it.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
test-esm.mjs Adds ESM import test coverage for named exports.
package.json Introduces conditional exports + subpath exports; updates scripts to run ESM tests and adds a prepare hook.
index.mjs New ESM entrypoint that re-exports JSON-backed values as named exports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

zkochan added 9 commits March 24, 2026 16:07
Self-referencing the package name doesn't work in CI because
pnpm doesn't create a self-link in node_modules for non-workspace packages.
Rename updateList.ts to .mts and run with
node --experimental-strip-types. This fixes CI where ts-node
failed to compile import.meta.url in CJS mode.
Drop type annotations and use .mjs instead of .mts to avoid
needing ts-node or --experimental-strip-types flag.
Run node updateList.mjs directly instead of pnpm update-list
to avoid pnpm beta crash on non-native Error objects.
@zkochan zkochan merged commit 43e0b16 into main Mar 24, 2026
1 check passed
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.

2 participants