Conversation
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.
There was a problem hiding this comment.
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.mjsto provide ESM named exports (TRUSTED_PACKAGE_NAMES,DEFAULT_ALLOW_BUILDS). - Added
exportsmap inpackage.jsonfor conditional ESM/CJS entry resolution and subpath exports for JSON +pnpmfile.cjs. - Added
test-esm.mjsand 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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
index.mjswith proper ESM named exports (TRUSTED_PACKAGE_NAMES,DEFAULT_ALLOW_BUILDS)exportsfield inpackage.jsonso ESM consumers getindex.mjsand CJS consumers getindex.js./allowBuilds.json,./allow.json, and./pnpmfile.cjstest-esm.mjs)This enables pnpm to use
import { DEFAULT_ALLOW_BUILDS } from '@pnpm/plugin-trusted-deps'without CJS interop issues.Test plan