Repository navigation
fix(externals): externalize a package's own entry as its bare name - #4683
Conversation
guessSubpath built the external id with join(name, e.subpath). The "." export is flattened to the subpath "./", so a traced package imported by the absolute path of its own entry became "dep/", and the output failed at startup with ERR_PACKAGE_PATH_NOT_EXPORTED. Return the bare name for that export and leave named and wildcard subpaths as they were. Fixes nitrojs#4678
|
@hungateJoseph is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Replace the guessSubpath unit test, which used resolve conditions nitro never passes, with a fixture route that imports a traced package's conditional "." export by absolute path.
# Conflicts: # test/presets/vercel.test.ts
commit: |
🔗 Linked issue
Fixes #4678
❓ Type of change
📚 Description
When a traced dependency is imported by the absolute path of the file its
"."export points at,guessSubpathlooks the file up in the package's flattened exports and builds the external id withjoin(name, e.subpath).flattenExportsgives the"."entry the subpath"./", so the id came out asdep/, and the output then failed at startup withERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './' is not defined by "exports".The
"."export is the package itself, so that case now returns the bare package name. Named and wildcard subpaths are unchanged.guessSubpathis exported so it can be tested on its own, alongside the other helpers this file already exports for tests. The new unit test builds a small package in a tempnode_moduleswith a conditional"."export, a named subpath and a wildcard subpath. The"."cases fail onmainwithexpected 'dep/' to be 'dep'and pass with this change, alongside the existingtrace-depstests.📝 Checklist