Skip to content

fix: prevent source map references from being resolved - #3220

Open
golden-fox07 wants to merge 2 commits into
npmx-dev:mainfrom
golden-fox07:fix/docs-resolver-sourcemap
Open

fix: prevent source map references from being resolved#3220
golden-fox07 wants to merge 2 commits into
npmx-dev:mainfrom
golden-fox07:fix/docs-resolver-sourcemap

Conversation

@golden-fox07

@golden-fox07 golden-fox07 commented Aug 31, 2026

Copy link
Copy Markdown

🔗 Linked issue

Resolves: #2739

🧭 Context

  • index.d.ts.map was getting treated as a package name because it didnt start with .
  • This was causing a lot of failed requests to esm.sh (143 out of 440)

📚 Description

  • .map references are now skipped by the resolver
  • I checked if resolving them normally would work but esm.sh doesn't serve the .d.ts.map files anyway
  • Added tests for the source map case
  • The docs output stays the same and the unnecessary requests are gone

Open Question

I put the check in the resolver since thats where the misclassification happens. It relies on createLoader ignoring non http(s) urls though

  • would you prefer an explicit .map skip in the loader too?

@agentscanapp

agentscanapp Bot commented Aug 31, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! 🎉

We really appreciate you taking the time to contribute, @golden-fox07.

A maintainer will take a look as soon as they can. In the meantime, please make sure that:

  • the description explains what changed and why
  • any related issues are linked
  • existing tests still pass

If anything needs adjusting we'll leave comments here. Thanks again!

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview Aug 31, 2026 1:36pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Aug 31, 2026 1:36pm
npmx-lunaria Ignored Ignored Aug 31, 2026 1:36pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f28b49b8-93cb-4dc5-9005-20226002a46e

📥 Commits

Reviewing files that changed from the base of the PR and between 309c724 and 2515681.

📒 Files selected for processing (2)
  • server/utils/docs/client.ts
  • test/unit/server/utils/docs/client.spec.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Source map references now remain unchanged during documentation module resolution, preventing incorrect package resolution.
    • Relative imports, absolute paths, package references, URLs and Node.js built-ins continue to resolve appropriately.
  • Tests

    • Added coverage for module resolution behaviour, including source map references and supported import formats.

Walkthrough

Changes

Documentation resolver

Layer / File(s) Summary
Export and source map guard
server/utils/docs/client.ts
createResolver is now exported. Specifiers ending in .map are returned unchanged.
Resolver behaviour tests
test/unit/server/utils/docs/client.spec.ts
Tests cover source map references and existing handling for relative imports, absolute paths, bare specifiers, URLs, and Node builtins.

Merge Risk: ⚪ Minimal · up to 25156

The resolver now leaves source map references unchanged, preventing unnecessary failed requests without changing normal documentation output. No actionable merge-blocking risk remains beyond normal checks.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: preventing source map references from being resolved. It is concise and uses a conventional commit format.
Description check ✅ Passed The description directly explains the source map resolution bug, the fix, the tests, and the expected reduction in unnecessary esm.sh requests.
Linked Issues check ✅ Passed The changes satisfy issue #2739 by skipping specifiers that end in .map, preventing invalid esm.sh requests. The added tests cover the source map cases and preserve expected resolver behaviour.
Out of Scope Changes check ✅ Passed The exported createResolver function and its tests directly support the fix for issue #2739. No unrelated code changes are identified.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
server/utils/docs/client.ts 50.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@golden-fox07 golden-fox07 changed the title Fix docs resolver sourcemap fix: prevent source map references from being resolved Aug 31, 2026
@golden-fox07
golden-fox07 marked this pull request as ready for review August 31, 2026 13:45
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.

getDocNodes() handles sourceMappingURL poorly, causes bad requests to esm.sh

1 participant