Commit activity
Last 12 weeks · 4 commits
Community health
3 of 6 standards met
Recent PRs & issues
Describe the bug https://pnpm.io/global-virtual-store With this mode enabled, the modules live in , so the strategy doesn't work. Used Package Manager pnpm Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. Contributions [ ] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
🔗 Linked issue Fixes https://github.com/antfu-collective/local-pkg/issues/16 🧭 Context 📚 Description Previously, fell back to resolving the package entrypoint and walking up directories, which could land on a nested (e.g. in ) instead of the root one, resulting in the wrong being resolved. This PR enhances the resolve algorithm to address this issue, borrowing the implementation from , which correctly replicates the node.js resolve algorithm.
Describe the bug I'm trying to of but it seems like it finds the wrong package.json, and thus I cannot get the package version since it is . Reproduction https://stackblitz.com/edit/vitejs-vite-5orkssas System Info Used Package Manager pnpm Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [x] The provided reproduction is a minimal reproducible of the bug. Contributions [ ] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
Recent fixes
Problem is slow when the package is not installed. The cost grows with each path in . calls mlly two times. For each path, mlly tries 4 URLs and 9 specifier variants. Each attempt walks all ancestors. Almost all of these calls repeat. Nuxt modules such as and pass one path for each layer. In a production app with 22 layers, these checks used 7.8 s of CPU during start-up. Fix now does a quick check before it calls mlly. The check looks in each distinct ancestor of the paths for: , or `.js.mjs.cjs.jsonpackage.jsonresolvePackagefalse#normalizeidpackage.jsonENOTDIRfalse` without a log. Repro: https://github.com/onmax/repros/tree/repro/local-pkg-is-package-exists-paths/local-pkg-is-package-exists-paths
Describe the bug treats any error code other than the two module-not-found codes as unexpected and prints it to the console: https://github.com/antfu/local-pkg/blob/3da6302e7a/src/index.ts#L108-L116 When a path segment on the resolution walk is a file rather than a directory, Node throws . Semantically that is the same answer as — the package is not there — and the function handles it correctly by returning . But it also dumps a full stack trace to stderr on the way out. In a dev-server / bundler pipeline that calls this repeatedly, the result is recurring, alarming-looking output for a non-event. It is easy to mistake for a real failure because the surrounding code carries on normally. Reproduction Resolve a package name whose walk passes through a regular file as if it were a directory (for example a path where an intermediate entry is a file). returns as expected, and an stack trace is printed. Suggested fix Treat like the other not-found codes: Happy to send this as a PR if you'd like it in that form. Environment , Node 25.9.0, macOS 26.5.1 (arm64)
Summary When walks a path whose intermediate segment is a regular file (not a directory), Node/mlly throws . That is semantically the same as not finding the package, and the function already returned — but it also dumped a full stack trace via , which is noisy in bundler/dev-server pipelines that call this repeatedly. Treat like / : return quietly. Fixes #21 Test plan [x] Added that points at a file so resolution hits , asserts / return not-found, and asserts is not called [x] (vitest + esm smoke) passes locally
Repository: made-in-common/local-pkg. Description: Get information on local packages. Stars: 186, Forks: 18. Primary language: TypeScript. Languages: TypeScript (88.8%), JavaScript (11.2%). License: MIT. Latest release: v2.0.0 (3w ago). Open PRs: 2, open issues: 2. Last activity: 1d ago. Community health: 50%. Top contributors: antfu, sxzz, chizukicn, xeho91, onmax, qmhc, webywz.