Skip to content

[lexical-website] Refactor: Drop docusaurus-plugin-internaldocs-fb preset#8516

Merged
etrepum merged 2 commits into
mainfrom
zurfyx/drop-internaldocs-fb-plugin
May 14, 2026
Merged

[lexical-website] Refactor: Drop docusaurus-plugin-internaldocs-fb preset#8516
etrepum merged 2 commits into
mainfrom
zurfyx/drop-internaldocs-fb-plugin

Conversation

@zurfyx
Copy link
Copy Markdown
Member

@zurfyx zurfyx commented May 14, 2026

Description

The lexical.dev site was using docusaurus-plugin-internaldocs-fb's preset purely as a wrapper around @docusaurus/preset-classic — none of its Meta-internal features were actually used.

Per @etrepum's question on #8509: yes, we can clean it up.

What it was costing the public site

  • A fetch('https://staticdocs.thefacebook.com/ping') fired on every page navigation. The host is unreachable from outside Meta corpnet, producing two net::ERR_NAME_NOT_RESOLVED errors per route change in the console (the second staticdocs.thefacebook.com/ping pair in Bug: Errors appear in the browser console immediately on lexical.dev page load #8103).
  • A hidden <div id="internaldocs-banner"> injected into <body> on every page.
  • A postMessage('page-update', '*') to window.parent on every route update.
  • A copy event listener pinging Meta-internal feedback.reportContentCopied.
  • A duplicate copy of docs/ in build/_src/ (plugin postBuild artifact).
  • ~1.2k lines of transitive deps (react-modal, react-live, mermaid v11, node-fetch@2, docusaurus-lunr-search, etc.) in pnpm-lock.yaml.

What it was contributing to the public site

Almost nothing actually load-bearing:

  • docs/error.md imported OssOnly from the plugin and wrapped <ErrorCodePage/> in it. <OssOnly> is a no-op when FB_INTERNAL isn't set, so the wrapper had no effect on the public build.
  • src/pages/gallery.md imported FBInternOnly from the plugin… but the actual export name is FbInternalOnly, so the import resolved to undefined. The component was never rendered. Pure dead code.
  • No fb/*.mdx pages, no fbContent / fbInternalOnly call sites anywhere in packages/lexical-website/.
  • No D###### / T###### / fburl.com / pixelcloud:// references in docs that depended on the internLinks / pixelcloud remark plugins.

Migration

  • Replaced require.resolve('docusaurus-plugin-internaldocs-fb/docusaurus-preset') with 'classic' in docusaurus.config.ts. Dropped the staticDocsProject: 'lexical' option (preset-classic doesn't take it).
  • Removed the dead OssOnly import + wrapper in docs/error.md.
  • Removed the dead/typo'd FBInternOnly import in src/pages/gallery.md.
  • Dropped the dep in package.json; lockfile reflects the cleanup.
  • Removed packages/lexical-website/fb/sdoc-cache.json (plugin-only artifact, no longer needed).

One implementation detail worth flagging

The plugin's webpack EnvironmentPlugin was substituting process.env.FB_INTERNAL at build time, which let webpack tree-shake the dynamic imports in GalleryCards.tsx:

useEffect(() => {
  if (process.env.FB_INTERNAL) {
    import('../../../../InternGalleryCards').then(setInternGalleryCards);
    import('../../../../InternGalleryTags').then(setInternGalleryTags);
  }
}, []);

Without the substitution, webpack tries to statically resolve those imports and fails the public build (those modules don't exist in this repo).

Added a small local plugin (packages/lexical-website/plugins/webpack-fb-internal/index.js) that does the same DefinePlugin substitution. Keeps the gallery code untouched and continues to work for the internal build.

Test plan

  • pnpm install — lockfile drops 16 top-level + many transitive entries; no surprise additions.
  • pnpm --filter @lexical/website run build — succeeds cleanly. The two warnings (@huggingface/transformers import.meta, HTML minifier on /docs/api/) are pre-existing on main, unrelated to this change.
  • pnpm exec docusaurus serve — homepage / /docs/intro / /docs/error / /gallery all 200; search index served; <title> and content render the same.
  • grep staticdocs.thefacebook.com build/ returns nothing — no pings will fire from the production bundle.
  • grep -rE 'D[0-9]{6,}|T[0-9]{6,}|fburl\.com|pixelcloud://' packages/lexical-website/{docs,blog,src/pages} returns nothing — no auto-linkification lost.
  • tsc / prettier / eslint all clean (lint-staged on commit).

Out of scope (intentionally)

Closes

Closes part of #8103 (the staticdocs.thefacebook.com/ping pair).

…eset

The lexical.dev site was using docusaurus-plugin-internaldocs-fb's preset
purely as a wrapper around @docusaurus/preset-classic — none of its
Meta-internal features were actually used:

- The OssOnly wrapper in docs/error.md was a no-op on OSS builds.
- The FBInternOnly import in src/pages/gallery.md was dead code (and
  typo'd — the real export is FbInternalOnly, so the import resolved to
  undefined and never rendered).
- No fb/*.mdx pages, no fbContent / fbInternalOnly call sites.

Switching to @docusaurus/preset-classic directly:

- Removes the staticdocs.thefacebook.com/ping fetch fired on every page
  navigation (closes part of #8103 — the request fails for everyone outside
  Meta corpnet, producing two console errors per route change).
- Drops a duplicate copy of docs/ in build/_src/ (plugin postBuild artifact).
- Drops ~1.2k lines of transitive dependencies (react-modal, react-live,
  mermaid v11, node-fetch@2, etc.) from pnpm-lock.yaml.
- Removes a hidden #internaldocs-banner element injected on every page.

Webpack-side, the plugin's EnvironmentPlugin used to substitute
process.env.FB_INTERNAL at build time, which let webpack tree-shake the
'internal-only' dynamic imports in GalleryCards.tsx. Replaced with a small
local plugin (plugins/webpack-fb-internal) that does the same DefinePlugin
substitution so the public build can drop those branches.

Internal Meta verification: pulled static_docs_site_hits_30d for site=lexical
on 2026-05-13 — 11 hits, 1 user. Down ~10x YoY (was 117/20). All residual
traffic goes to pages that also exist on lexical.dev. No internal-only
content lost.

Test plan:
- pnpm install — lockfile drops 16 top-level + many transitive deps.
- pnpm --filter @lexical/website run build — succeeds.
- pnpm exec docusaurus serve — homepage, /docs/intro, /docs/error, /gallery
  all 200; search index present; build output contains zero references to
  staticdocs.thefacebook.com.
- Hand-checked gallery + error pages render the same content (the wrapped
  components were unconditionally rendered before).

Closes part of #8103.

Co-authored-by: Bob Ippolito <bob@redivi.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 2026

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment May 14, 2026 3:38pm
lexical-playground Ready Ready Preview, Comment May 14, 2026 3:38pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 14, 2026
@zurfyx zurfyx added the extended-tests Run extended e2e tests on a PR label May 14, 2026
…ck-fb-internal plugin

Removes the dynamic-import branch in GalleryCards.tsx that loaded
InternGalleryCards / InternGalleryTags modules from the parent directory.
Those modules don't exist in this repo — they only existed alongside the
synced lexical-website tree on the internal mirror. With the internal
publishing path going away, that code path has no consumers; keeping it
required a webpack DefinePlugin shim purely to let webpack tree-shake the
dead branch out of the public bundle.

Drops both:
- plugins/webpack-fb-internal/ (the shim)
- The if (process.env.FB_INTERNAL) useEffect in GalleryCards.tsx
- Now-unused useState / useEffect imports and intern* state in GalleryCards
- The Tag re-import in GalleryCards (only TagList is used)

The remaining process.env.FB_INTERNAL references in docusaurus.config.ts
and sidebars.js run at Node config-load time, not in the client bundle, so
they don't need substitution. ErrorCodePage.tsx's !process.env.FB_INTERNAL
branch resolves to !undefined === true on the public site, which is the
intended behavior — the import target is a real file in this repo.

Test plan:
- pnpm --filter @lexical/website run build — succeeds, same two pre-existing
  warnings as main (unrelated huggingface import.meta + minifier on docs/api).
- pnpm exec docusaurus serve — homepage / docs/intro / docs/error / gallery
  all 200; gallery renders OSS plugin cards correctly.
- grep InternGalleryCards build/ — no references in production bundle.
Copy link
Copy Markdown
Contributor

@potatowagon potatowagon left a comment

Choose a reason for hiding this comment

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

mariekondo

@etrepum etrepum added this pull request to the merge queue May 14, 2026
Merged via the queue into main with commit 0e2b347 May 14, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants