Given a package name and a version number, or a path to a package.json, what specifiers does it expose?
by ljharbJavaScript
Last 12 weeks · 5 commits
4 of 6 standards met
### What Updated index.js to follow Node’s subpath export rules: Only the first is treated as a wildcard. Mismatched or extra stars are treated as literal or not exported. RHS patterns expanded with fast-glob@3.2.11. Flattened star-handling logic to satisfy ESLint rules. Added tests in ex-stars-basic.test.js: hooks/useA resolves multi, mismatch not exported rhs-extra → MODULE_NOT_FOUND literal/ resolves as literal file Added fixture + expected snapshots in tests/fixtures/ex-stars-basic. ### Why Node only supports the first in subpath patterns. Our tool previously treated later stars incorrectly. Using ensures RHS patterns like expand to real files instead of being treated as a literal filename. Added tests provide clear parity with Node’s actual resolution behavior. ### Verification Confirmed with Node in a sandbox: outcomes ( vs ) match Node behavior. All tests (, ) and lint pass locally.
Summary Improved and updated the README.md with: Clear installation instructions CLI usage example Running tests guide Contributing guide Cleaner formatting with all original information preserved Fixed linting errors by adjusting the ESLint configuration and running --fix Resolved test syntax errors and ensured tests pass locally Verified code style compliance with Prettier and ESLint Changes ✅ Updated ✅ Fixed to be CommonJS compatible and cleaned up ✅ Fixed lint script in to avoid missing path errors () ✅ Ran tests and verified they pass with Node.js
As shown by #40 , there are some outdated dependencies. The versions of those dependencies should be updated and test ran to make sure nothing broke I suggest updating as many dependencies as possible in one PR (skip the ones that may be breaking code). Keep in mind that it may not be as easy to just update versions in package.json. Some dependencies need code changed as well
Update eslint from 8.8.0 to 8.57.1 across all packages Update @npmcli/arborist from ^7.5.4 to ^9.1.2 Update npm-packlist from ^8.0.2 to ^10.0.0 Update semver from ^7.6.3 to ^7.7.2 in list-exports Update semver from ^6.3.1 to ^7.7.2 in tests Update npm-package-arg from ^11.0.3 to ^12.0.2 Update pacote from ^18.0.6 to ^21.0.0 in ls-exports Update pacote from ^17.0.7 to ^21.0.0 in tests Update strip-ansi from ^6.0.1 to ^7.1.0 Update yargs from ^17.7.2 to ^18.0.0 Update jackspeak from =2.1.1 to =4.1.1 Update resolve from ^2.0.0-next.4 to ^1.22.10 All tests continue to pass with updated dependencies.
List-exports incorrectly adds as possible entry point when requesting all exports with conditions enabled: https://github.com/ljharb/list-exports/blob/84a90dcc33bf85b32ef37732e2017ffd1a2146ff/packages/tests/fixtures/preact/expected-without-conditions.json#L9 However, using node 13 require('preact') Thrown: Error: Package exports for '/private/var/folders/_d/ch2kc4h960d10cy_2c41qqzw0000gn/T/tmp.4w99c5aIqE/node_modules/preact' do not define a valid '.' target at resolveExportsTarget (internal/modules/cjs/loader.js:460:13) at resolveExports (internal/modules/cjs/loader.js:393:16) at Function.Module._findPath (internal/modules/cjs/loader.js:492:20) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:787:27) at Function.Module._load (internal/modules/cjs/loader.js:693:27) at Module.require (internal/modules/cjs/loader.js:864:19) at require (internal/modules/cjs/helpers.js:74:18) { code: 'MODULE_NOT_FOUND' } ``.../` later on.
Continuation of #78 which I inadvertently closed by deleting the fork repo. Adds a fixture with a remapped folder, where the remapped name also exists. The example is a bit contrived, but it does showcase two bugs: 1. The export is mapped onto , making it impossible to require any of the files in the actual folder. The file does show up in the result. This is linked to #77 2. The doesn't show the mapping In other words, I'd expect
Repository: ljharb/list-exports. Description: Given a package name and a version number, or a path to a package.json, what specifiers does it expose? Stars: 15, Forks: 6. Primary language: JavaScript. Languages: JavaScript (100%). License: MIT. Open PRs: 2, open issues: 4. Last activity: 2w ago. Community health: 85%. Top contributors: ljharb, bgotink, renovate-bot.