Skip to content

feat(wip): add per-entrypoint API docs pages for multi-export packages#1728

Draft
serhalp wants to merge 1 commit intomainfrom
serhalp/fix-deno-docs-links
Draft

feat(wip): add per-entrypoint API docs pages for multi-export packages#1728
serhalp wants to merge 1 commit intomainfrom
serhalp/fix-deno-docs-links

Conversation

@serhalp
Copy link
Member

@serhalp serhalp commented Feb 28, 2026

🔗 Linked issue

Fixes #1479

🧭 Context

Packages with only subpath exports (no . export) previously got no docs because esm.sh (our source of truth for this) returns 404 for their root URL.

📚 Description

Fall back to the npm registry exports field to discover typed subpath entries.

Additionally, multi-entrypoint packages now get separate docs pages per subpath with an entrypoint selector dropdown, as dumping all symbols into one flat page would be misleading. The base URL redirects to the "first" entrypoint (arbitrary).

The route now looks like /package-docs/:pkg/v/:version/:entrypoint.

Warning

Don't look at the diff. This was a quick AI spike to play with the approach 😶.

Packages with only subpath exports (no root export) previously got no
docs because esm.sh returns 404 for their root URL. Fix by falling back
to the npm registry  field to discover typed subpath entries.

Additionally, multi-entrypoint packages now get separate docs pages per
subpath with an EntrypointSelector dropdown, instead of dumping all
symbols into one flat page. The base URL redirects to the first
entrypoint.

URL structure: /package-docs/{pkg}/v/{version}/{entrypoint}

Closes #1479
@vercel
Copy link

vercel bot commented Feb 28, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 28, 2026 1:03am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Feb 28, 2026 1:03am
npmx-lunaria Ignored Ignored Feb 28, 2026 1:03am

Request Review


// Mock encodePackageName
vi.mock('#shared/utils/npm', () => ({
encodePackageName: (name: string) => name.replace('/', '%2f'),

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High documentation test

This replaces only the first occurrence of '/'.

Copilot Autofix

AI 2 days ago

In general, when escaping or encoding characters with String.prototype.replace, use a regular expression with the global (g) flag so that all occurrences are replaced, not just the first one. For URL-style encoding of all / characters, the pattern should be /\//g.

For this specific case, update the mocked encodePackageName implementation in test/unit/server/utils/docs/client.spec.ts so that it replaces every / in name, not just the first. Change:

  • Line 11 from name.replace('/', '%2f')
  • To name.replace(/\//g, '%2f')

No additional imports or helper methods are required; this uses built-in JavaScript regex support. This preserves existing behavior for inputs with zero or one /, while correctly handling inputs with multiple / characters.

Suggested changeset 1
test/unit/server/utils/docs/client.spec.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test/unit/server/utils/docs/client.spec.ts b/test/unit/server/utils/docs/client.spec.ts
--- a/test/unit/server/utils/docs/client.spec.ts
+++ b/test/unit/server/utils/docs/client.spec.ts
@@ -8,7 +8,7 @@
 
 // Mock encodePackageName
 vi.mock('#shared/utils/npm', () => ({
-  encodePackageName: (name: string) => name.replace('/', '%2f'),
+  encodePackageName: (name: string) => name.replace(/\//g, '%2f'),
 }))
 
 // Mock Nitro globals before importing the module.
EOF
@@ -8,7 +8,7 @@

// Mock encodePackageName
vi.mock('#shared/utils/npm', () => ({
encodePackageName: (name: string) => name.replace('/', '%2f'),
encodePackageName: (name: string) => name.replace(/\//g, '%2f'),
}))

// Mock Nitro globals before importing the module.
Copilot is powered by AI and may make mistakes. Always verify output.
@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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.

api docs don't generate when package is missing default export

1 participant