Skip to content

Conversation

charliecreates[bot]
Copy link
Contributor

@charliecreates charliecreates bot commented Oct 12, 2025

Rollup Plugin Name: @rollup/plugin-node-resolve

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

resolves #1907

Description

Fixes resolution when a package.json imports entry maps to a bare specifier (e.g. "#foo/*": "@scope/pkg/*"). Previously these targets were resolved via the classic resolver which ignores the target package's exports, causing failures for packages that rely on export maps. The fix routes such targets through the export‑map‑aware path so subpath exports are honored.

Also guards against null from resolution to avoid fileURLToPath(null), surfacing a clearer ResolveError instead.

Included tests cover resolving #foo/* to a package that exposes subpaths via exports directory mappings. The new fixture is imports-bare-pattern-exports and the positive case passes with the change.

…port maps; avoid fileURLToPath(null)\n\n- When an imports mapping points to a bare specifier (e.g. "#foo/*": "@scope/pkg/*"), resolve the target with the full export-map-aware algorithm instead of classic only.\n- Guard against null return to prevent TypeError from fileURLToPath(null).\n- Add test: imports pattern -> bare package that uses exports.\n\nFixes #1907
Copy link
Contributor Author

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly routes bare imports targets through the export-map-aware resolver and prevents a TypeError by guarding against null. Error messaging can be clearer by explicitly handling undefined and by presenting a friendly path for the importer. Consider adding a negative test to lock in the improved failure behavior. No correctness or compatibility issues spotted in the changed logic.

Additional notes (2)
  • Readability | packages/node-resolve/src/resolveImportSpecifiers.js:155-162
    Good addition to guard against null. Two improvements would make this error path more actionable and explicit:

  • Be explicit about null vs undefined rather than relying on == null.

  • Include a friendlier, filesystem-path version of importer (when it’s a file URL) and clarify that the failure is via package.json imports.

This improves debuggability without changing behavior.

  • Maintainability | packages/node-resolve/test/package-entry-points.js:352-368
    Nice positive test. Given the bug fix also changes the failure mode (avoids fileURLToPath(null)), it would be valuable to add a negative test that asserts a ResolveError with a clear message when an imports target cannot be resolved. This helps prevent regressions on the newly introduced error path.
Summary of changes
  • In resolveWithExportMap, targets of package imports that are bare specifiers are now resolved using the export-map-aware path by delegating to resolveImportSpecifiers instead of the classic resolver.
  • Added a null guard to prevent fileURLToPath(null), throwing a ResolveError with a clearer message when resolution fails.
  • Added new test fixtures for a package whose imports pattern maps to a bare package that relies on exports subpath mappings.
  • Added a test verifying resolution of #foo/* -> exports-directory/foo/* via a bare package that exposes subpaths through exports.

See: fix for handling bare targets in imports and improved failure behavior.

@charliecreates charliecreates bot removed the request for review from CharlieHelps October 12, 2025 11:24
@shellscape
Copy link
Collaborator

@CharlieHelps use the PR template. future PRs that do not use the template will be closed without explanation.

@charliecreates
Copy link
Contributor Author

charliecreates bot commented Oct 12, 2025

Expand this to see my work.
  • Updated the PR #1908 description to match .github/PULL_REQUEST_TEMPLATE.md (populated required sections and normalized headings), with no code changes.

@charliecreates
Copy link
Contributor Author

@shellscape thanks for the reminder—updated the PR description to use the repository template.

I’ll use the template for future PRs.

@shellscape shellscape merged commit 3569720 into master Oct 13, 2025
8 of 14 checks passed
@shellscape shellscape deleted the ai-1907-rollup-plugin-node-resolve-the-path-argume branch October 13, 2025 00:31
@shellscape
Copy link
Collaborator

@CharlieHelps what are my remaining credits/tokens?

@charliecreates
Copy link
Contributor Author

@shellscape I can’t see org billing from a GitHub thread. To check your remaining credits, open the Charlie dashboard and go to Manage → Billing & Usage (select your GitHub org if prompted). That page shows current balance and recent usage. (docs.charlielabs.ai)

For context, PR reviews are free; typical costs are: messages 5 credits, a commit 20, simple PR 100, complex PR 200. Plan pages list monthly included credits (e.g., 10,000 on Startup). (charlielabs.ai)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@rollup/plugin-node-resolve The "path" argument must be of type string or an instance of URL. Received null

2 participants