node:module: implement findPackageJSON - #37924
eduardoaugustolb wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
WalkthroughChangesThe findPackageJSON resolution
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for this. I opened #37947, which keeps your commit as its first commit and reworks the lookup on top of it so it matches Node on the documented cases (for example |
Fixes #23898.
Root cause
node:moduledid not export or implementfindPackageJSON, so a named ESM import failed before the call could run.Change
Expose a native
findPackageJSONbinding and resolve through Bun’s existing ESM resolver, returning the selected package’spackage.json. This preserves ESM package resolution for bare specifiers and resolved file URLs.Validation
The added regression test runs both
findPackageJSON("pkg", import.meta.url)and the issue-shapedfindPackageJSON(import.meta.resolve("pkg")). It fails on the unfixed system Bun withExport named 'findPackageJSON' not found in module 'node:module'.\n\nValidated in Docker:\n\nsh\nbun bd test test/js/node/module/node-module-module.test.js\n\n\nResult: 38 passed, 1 pre-existing skip.