fix(env): strip trailing slash from node: builtin specifiers (#555)#557
fix(env): strip trailing slash from node: builtin specifiers (#555)#557tsushanth wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR adds trailing-slash normalization to the ChangesNode Builtin Trailing Slash Normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Apologies @ashtonjurgens — your #556 was open about 6 hours before this and touches the exact same files ( |
Closes #555.
When an alias chain feeds
_resolvea value likepunycode/,pathe'sresolveAliasrewrites it through thepunycode -> node:punycodemapping and tacks the trailing slash back on, producingnode:punycode/. That string then hits theid.startsWith("node:")short-circuit and was returned verbatim. Node rejects the resulting specifier withERR_UNKNOWN_BUILTIN_MODULEbecause trailing slashes are not legal onnode:builtins, even though the equivalent package formpunycode/is fine.The fix normalises only inside the
node:branch and only when the trimmed name is a real builtin. So:node:punycode/->node:punycode(the bug)node:punycode-> unchangednode:not-a-real-builtin/-> unchanged (no surprise rewrites of unknown values)node:strings -> unchanged pathThis keeps the regular package-path behaviour the issue calls out (
my-module/staysmy-module/).Tests
Three new cases under
describe("resolvePath")intest/env.test.ts:punycode/resolves tonode:punycodenode:punycodealias stays unchangednode:not-a-real-builtin/alias is left aloneAll three pass with the patch and fail (or never run) against
main. The pre-existingresolves all nodeCompat pathsfailure onmain(unenv/node/inspector/promisesmissing) is unrelated; confirmed by running the suite onmainwithout these changes.Summary by CodeRabbit
Release Notes