Repository navigation
[lexical-website] Bug Fix: resolve external API links and shorten submodule labels - #9220
Merged
Merged
Conversation
## Description
The API reference emits source URLs pointing into Lexical's `node_modules` and leaves dependency types unlinked. Those files are not in the repository.
- Use TypeDoc documentation mappings for browser/JavaScript types, TypeScript utility types, React, mdast/unist, markdown utilities, Yjs, and fast-check. No new dependencies are needed.
- Fall back to the exact installed package/version/file on UNPKG for other external types and dependency source references. Preserve Lexical's own source links and display dependency paths without the install layout.
- Keep line numbers in source labels but omit UNPKG fragments, since its large-file viewer does not provide line anchors.
- Add rendering regressions for flat and pnpm installs, declaration/signature sources, inline links, mapping precedence, and an external `Node` that must not resolve to the DOM type.
## Test plan
### Before
Generated API Markdown using the original TypeDoc configuration:
```sh
rg -o '\]\([^)]*node_modules[^)]*\)' ../api-before | wc -l
```
```text
77
```
The conversion audit also found 131 unresolved dependency symbols.
### After
Website build (from `packages/lexical-website`): `IGNORE_PEER_DEPENDENCIES=react node node_modules/@docusaurus/core/bin/docusaurus.mjs build`:
```text
[SUCCESS] Generated static files in "build".
```
`node node_modules/vitest/vitest.mjs run --project scripts-unit scripts/__tests__/unit/typedocExternalLinks.test.ts`:
```text
Test Files 1 passed (1)
Tests 2 passed (2)
```
Generated-link audit, including HTTP destinations and documentation anchors:
```text
136 API pages; 0 node_modules links
102 distinct external links; 89 destination pages checked
Unverified or broken external targets: []
```
All 131 dependency symbols now resolve. Website TypeScript, targeted ESLint, Prettier, and `git diff --check` pass. The website build emits non-fatal TSDoc, third-party bundler, and API-index minifier warnings. Validated on Linux; browser and other OS suites were not run for this documentation-only change.
…d doc mappings
## Description
UNPKG source fallbacks currently discard working line anchors and omit documentation mappings for React JSX elements and Preact signal types. Dependencies without publishable manifests also retain installation paths in their source labels.
Use direct app.unpkg.com file URLs and preserve source lines for files within UNPKG's interactive viewer limits. Derive symbol lines from TypeDoc's source offsets, and keep file-only links for large files. Add React JSX and Preact signal/callback/disposer documentation mappings, while retaining actual source links for "Defined in". Clean dependency source labels even when no public URL can be generated.
## Test plan
### Before
Run the updated rendering regression against the previous implementation:
```sh
node node_modules/vitest/vitest.mjs run --project scripts-unit scripts/__tests__/unit/typedocExternalLinks.test.ts
```
```text
Test Files 1 failed (1)
Tests 2 failed (2)
```
The generated docs contained 78 React JSX source fallbacks.
### After
Run the same rendering regression, including flat/pnpm installs, CRLF and Unicode offsets, declaration/signature lines, both UNPKG viewer limits, and private/missing manifests:
```text
Test Files 1 passed (1)
Tests 2 passed (2)
```
Generated API audit:
- 136 pages, zero node_modules URLs.
- All 78 React JSX references link to React documentation.
- Three Preact callback/disposer references now link to documentation; 28 "Defined in" references retain exact source links.
- 93 distinct UNPKG links, including 90 verified line anchors. All remaining destinations were covered by the HTTP/anchor audit.
- Preact documentation anchors verified against their destination page.
Website TypeScript, targeted ESLint, Prettier and git diff --check pass. Validated on Linux; browser and other OS suites were not run for this documentation-only change. The site compilation and generated-link checks completed; rebuilding into the reused output directory failed at final redirect creation because the redirect already existed.
## Description The API sidebar already groups non-React submodules under their packages, but their labels repeat the full package prefix and wrap unnecessarily. Use TypeDoc's exact module titles to display short submodule names in every generated package category, including nested categories. This applies the existing React navigation convention to extension, compiler, headless, internal, and other packages without package-specific rules. ## Test plan ### Before Run the sidebar probe against the website's actual sidebarItemsGenerator and Docusaurus DefaultSidebarItemsGenerator using the generated document metadata: ```sh node ../check-api-sidebar.mjs ``` ```text @lexical/compiler: 3 children, 3 labels repeat the package prefix @lexical/extension: 29 children, 29 labels repeat the package prefix @lexical/headless: 1 children, 1 labels repeat the package prefix @lexical/internal: 8 children, 8 labels repeat the package prefix @lexical/react: 60 children, 0 labels repeat the package prefix Labels repeating their package prefix: 41 ``` ### After ```sh EXPECT_SHORT=1 SIDEBAR_OUT=../api-sidebar-after.json node ../check-api-sidebar.mjs ``` ```text @lexical/compiler: 3 children, 0 labels repeat the package prefix @lexical/extension: 29 children, 0 labels repeat the package prefix @lexical/headless: 1 children, 0 labels repeat the package prefix @lexical/internal: 8 children, 0 labels repeat the package prefix @lexical/react: 60 children, 0 labels repeat the package prefix Labels repeating their package prefix: 0 All document and category targets preserved ``` A structural comparison confirms identical sidebar structure, ordering, document IDs, and category links. Website TypeScript, targeted ESLint, Prettier, and git diff --check pass. Validated on Linux; browser and other OS suites were not run for this navigation-label change. The full site bundle was not rebuilt; validation invokes the actual sidebar generators directly.
…y sources
## Description
TypeDoc resolves declaration maps for unknown-symbol filenames without remapping their declaration-file offsets. Using those offsets in the mapped source produces incorrect UNPKG line anchors, including Yjs Snapshot and Transaction.
Only derive unknown-symbol anchors when the filename matches /\.d\.[cm]?ts$/. Keep mapped-source links at the file level and preserve SourcePlugin's declaration-file anchors. Add a declaration-map rendering fixture for flat and pnpm installs that verifies both behaviors.
## Test plan
### Before
With the declaration-map fixture added before the resolver fix:
```sh
node node_modules/vitest/vitest.mjs run --project scripts-unit scripts/__tests__/unit/typedocExternalLinks.test.ts
```
```text
Test Files 1 failed (1)
Tests 2 failed (2)
```
### After
The same command passes:
```text
Test Files 1 passed (1)
Tests 2 passed (2)
```
Regenerated the API Markdown using the website's TypeDoc configuration and checked the resulting URLs:
```text
YJS: `Snapshot` https://app.unpkg.com/[email protected]/files/src/utils/Snapshot.js
YJS: `Transaction` https://app.unpkg.com/[email protected]/files/src/utils/Transaction.js
Yjs mapped-source links: 5; line anchors: 0
UNPKG links: 93; line anchors: 88
node_modules links: 0
```
Website TypeScript, targeted ESLint, Prettier, and git diff --check pass. Validated on Linux; the full website bundle, browser tests, and other operating systems were not rerun for this resolver-only change.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
marked this pull request as ready for review
September 24, 2026 16:58
etrepum
requested review from
acywatson,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
September 24, 2026 16:58
zurfyx
approved these changes
Sep 24, 2026
Merged
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The API reference emits source URLs pointing into Lexical's
node_modulesand leaves dependency types unlinked. Those files are not in the repository. The API sidebar also repeats package prefixes in non-React submodule labels, causing unnecessary wrapping.#L…anchors on directapp.unpkg.com/.../files/...URLs where UNPKG renders its interactive viewer (up to 50,000 characters and 2,000 lines). Keep file-only links for larger files. For unknown symbols, only use offsets when the filename ends in.d.ts,.d.cts, or.d.mts: TypeDoc resolves declaration-map filenames without remapping their offsets. Mapped-source links remain file-only; "Defined in" links retain their original declaration-file anchors.Nodethat must not resolve to the DOM type.Test plan
Before
Generated API Markdown using the original TypeDoc configuration:
The conversion audit also found 131 unresolved dependency symbols.
The updated line-anchor rendering regression failed against the previous implementation. The added declaration-map fixture also reproduces the invalid mapped-source anchors in both flat and pnpm installs:
Before the declaration-map guard, the regenerated Yjs type links pointed to
Snapshot.js#L1andTransaction.js#L28, although the classes are on lines 28 and 48 respectively.The actual Docusaurus sidebar generator also produced redundant labels:
After
node node_modules/vitest/vitest.mjs run --project scripts-unit scripts/__tests__/unit/typedocExternalLinks.test.ts:Website TypeScript, targeted ESLint, Prettier and
git diff --checkpass.Generated API audit:
The regenerated Yjs links now target
[email protected]/files/src/utils/Snapshot.jsand[email protected]/files/src/utils/Transaction.jswithout anchors. The declaration-map fixture confirms mapped-source links omit anchors while "Defined in" links still usemapped.d.ts#L2.All 78 React JSX references now link to React documentation. Three Preact callback/disposer references now link to its core documentation. The 28 Preact "Defined in" links still point to exact source locations; undocumented types retain source fallbacks.
The earlier HTTP audit confirmed the UNPKG destinations and anchor elements exist, plus all three new Preact documentation anchors. The declaration-map regression and regenerated API audit additionally check that mismatched source-file/declaration-offset pairs do not produce anchors. All 131 previously unresolved dependency symbols have links.
The full website build passed with the line-anchor changes. The subsequent build with the additional mappings completed site compilation and generation but failed at final redirect creation because the reused output directory already contained the redirect. A clean-output rerun was stopped after stalling during bundling; API generation, rendered regression tests, and the link audit all pass. Existing non-fatal TSDoc, third-party bundler and API-index minifier warnings remain.
Sidebar validation invokes the real default and custom Docusaurus generators against the generated document metadata:
A structural comparison confirms identical sidebar structure, ordering, document IDs, and category links. Website TypeScript, targeted ESLint, Prettier, and
git diff --checkwere rerun successfully for the navigation change. The full site bundle was not rebuilt for this label-only update.For the declaration-map fix, reran the rendering regressions, generated all 136 API pages, and passed website TypeScript, targeted ESLint, Prettier, and
git diff --check. The full website bundle was not rerun for this resolver-only fix.Validated on Linux; browser and other OS suites were not run for this documentation-only change.