8000 fix(externals): externalize a package's own entry as bare name (v2) (#4900) by agustin18 · Pull Request #4903 · nitrojs/nitro · GitHub
[go: up one dir, main page]

Skip to content

fix(externals): externalize a package's own entry as bare name (v2) (#4900) - #4903

Open
agustin18 wants to merge 3 commits into
nitrojs:v2from
agustin18:fix/v2-externals-root-export-subpath-4900
Open

agustin18 wants to merge 3 commits into
nitrojs:v2from
agustin18:fix/v2-externals-root-export-subpath-4900

Conversation

@agustin18
Copy link
Copy Markdown

🔗 Linked issue

Resolves #4900 (backports #4683 to v2)

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)

📚 Description

When resolving an absolute entry path for a package whose resolved file differs from the default entry (e.g. conditional exports like in @vue/shared), lookupNodeModuleSubpath(id) reverse-engineers the export subpath. For the package root export ".", it returns "./".

In Nitro v2, join(pkgName, "./") produces ${pkgName}/. Resolving that trailing-slash specifier triggers Node [DEP0155] DeprecationWarning and returns undefined, which causes Nitro to fall back to inlining the external dependency into the bundle.

This backports the fix from #4683 to v2: when guessedSubpath is "./" or ".", externalize the package by its bare name rather than appending a trailing slash.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel
vercel Bot commented Oct 22, 2026
Copy link
Copy Markdown

@agustin18 is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
coderabbitai Bot commented Oct 22, 2026 •
Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fb7b5315-d90f-4d82-99b9-481d3680fa15

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@pkg-pr-new
pkg-pr-new Bot commented Oct 22, 2026 •
Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitropack@4903

commit: 08f43d4

@pi0 pi0 added the v2 label Oct 23, 2026
@pi0x
pi0x commented Oct 29, 2026
Copy link
Copy Markdown
Contributor

Pushed a fix so the bare package name is only used when it resolves to the same package copy and the file is a "." export under the active conditions. Without this, a require-only root export, a nested older copy, or a dual package's CJS file could break or load the wrong version at runtime; tests added for the first two.

Triaged with AI assistance.

@nitrojs nitrojs temporarily blocked agustin18 Nov 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0