Skip to content

[lexical-html][lexical-website] Breaking change: give BlockIdHTMLExtension its own entry point - #9474

Merged
potatowagon merged 7 commits into
meta:mainfrom
potatowagon:blockid-html-entry-point
Oct 28, 2026
Merged

potatowagon merged 7 commits into
meta:mainfrom
potatowagon:blockid-html-entry-point

Conversation

@potatowagon

Copy link
Copy Markdown
Contributor

Description

@lexical/html is a single-entry package, so its barrel is the unit of
inclusion for anything that consumes the built bundle rather than the source.
Since #9421 that barrel re-exports BlockIdHTMLExtension, and that module
imports BlockIdExtension from @lexical/extension at module scope. Every
app that uses $generateHtmlFromNodes, the DOM import pipeline, or anything
else in @lexical/html therefore pulls in the whole BlockId implementation,
whether or not it opts into block ids in HTML. In the CommonJS (--www)
build, where the bundle file is atomic, there is no way to drop it.

This makes @lexical/html a two-entry package, the way @lexical/extension
already is:

  • @lexical/html — everything it exported before, less the three BlockId
    HTML symbols.
  • @lexical/html/BlockIdHTMLExtension — BlockIdHTMLExtension,
    BlockIdHTMLConfig and BLOCK_ID_ATTRIBUTE.

updateVersion.mjs derives exports from the top-level files of src/, so
dropping main on its own would have made every internal module a public
subpath. Following the rule in AGENTS.md — "Helpers with only one owning
entry live under src/internal and are bundled into that entry, without
exposing additional public subpaths" — the eight internal modules move to
src/internal/, leaving exactly index.ts and BlockIdHTMLExtension.ts as
entry points. Those are pure renames plus import-path updates; no code
changed.

This does break the three symbols #9421 added, which the docs describe as
experimental. A compatibility re-export from the barrel would restore the
static import and undo the change, so there is none:
import {BlockIdHTMLExtension} from '@lexical/html' becomes
import {BlockIdHTMLExtension} from '@lexical/html/BlockIdHTMLExtension'.

Unrelated, but worth knowing: pnpm run update-tsconfig also wants to
rewrite the lexical/src/__tests__/utils path to assertNodeType.ts, which
makes pnpm run tsc fail. That line is left as it is on main.

Test plan

Before

@lexical/html has one entry point, and it carries BlockIdExtension:

$ pnpm run build --www --prod
$ ls packages/lexical-html/dist/*.prod.js
packages/lexical-html/dist/LexicalHtml.prod.js
$ grep -c LexicalExtensionBlockIdExtension packages/lexical-html/dist/LexicalHtml.prod.js
1
$ wc -c packages/lexical-html/dist/LexicalHtml.prod.js
30463 packages/lexical-html/dist/LexicalHtml.prod.js

After

The barrel no longer reaches BlockIdExtension; the opt-in entry point does:

$ pnpm run build --www --prod
$ ls packages/lexical-html/dist/*.prod.js
packages/lexical-html/dist/LexicalHtml.prod.js
packages/lexical-html/dist/LexicalHtmlBlockIdHTMLExtension.prod.js
$ grep -c LexicalExtensionBlockIdExtension packages/lexical-html/dist/LexicalHtml.prod.js
0
$ grep -o 'require("LexicalExtensionBlockIdExtension")' packages/lexical-html/dist/LexicalHtmlBlockIdHTMLExtension.prod.js
require("LexicalExtensionBlockIdExtension")
$ wc -c packages/lexical-html/dist/LexicalHtml.prod.js
28988 packages/lexical-html/dist/LexicalHtml.prod.js

Checks:

$ pnpm run tsc
$ pnpm run tsc-test
$ pnpm run flow
Running Flow...
Found 0 errors
$ pnpm run lint
$ pnpm run prettier

Unit tests for the package, and the tree-shaking suites that bundle a bare
import of every entry point (the new one included):

$ pnpm vitest --project unit --no-watch packages/lexical-html
 Test Files  16 passed (16)
      Tests  139 passed (139)

$ pnpm vitest --project scripts-unit --no-watch treeShaking
 ✓ |scripts-unit| packages/lexical-compiler/src/__tests__/unit/treeShaking.test.ts (6 tests)
 ✓ |scripts-unit| scripts/__tests__/unit/treeShakingSource.test.ts (346 tests)
 Test Files  2 passed (2)
      Tests  352 passed (352)

pnpm run lint-flow reports the same 63 @lexical/html warnings before and
after this change, and its @lexical/yjs failures are likewise unchanged.
E2E and browser suites were not run.

…nsion its own entry point

## Description

`@lexical/html` is a single-entry package, so its barrel is the unit of
inclusion for anything that consumes the built bundle rather than the source.
Since meta#9421 that barrel re-exports `BlockIdHTMLExtension`, and that module
imports `BlockIdExtension` from `@lexical/extension` at module scope. Every
app that uses `$generateHtmlFromNodes`, the DOM import pipeline, or anything
else in `@lexical/html` therefore pulls in the whole BlockId implementation,
whether or not it opts into block ids in HTML. In the CommonJS (`--www`)
build, where the bundle file is atomic, there is no way to drop it.

This makes `@lexical/html` a two-entry package, the way `@lexical/extension`
already is:

- `@lexical/html` — everything it exported before, less the three BlockId
  HTML symbols.
- `@lexical/html/BlockIdHTMLExtension` — `BlockIdHTMLExtension`,
  `BlockIdHTMLConfig` and `BLOCK_ID_ATTRIBUTE`.

`updateVersion.mjs` derives `exports` from the top-level files of `src/`, so
dropping `main` on its own would have made every internal module a public
subpath. Following the rule in AGENTS.md — "Helpers with only one owning
entry live under `src/internal` and are bundled into that entry, without
exposing additional public subpaths" — the eight internal modules move to
`src/internal/`, leaving exactly `index.ts` and `BlockIdHTMLExtension.ts` as
entry points. Those are pure renames plus import-path updates; no code
changed.

This does break the three symbols meta#9421 added, which the docs describe as
experimental. A compatibility re-export from the barrel would restore the
static import and undo the change, so there is none:
`import {BlockIdHTMLExtension} from '@lexical/html'` becomes
`import {BlockIdHTMLExtension} from '@lexical/html/BlockIdHTMLExtension'`.

Unrelated, but worth knowing: `pnpm run update-tsconfig` also wants to
rewrite the `lexical/src/__tests__/utils` path to `assertNodeType.ts`, which
makes `pnpm run tsc` fail. That line is left as it is on `main`.

## Test plan

### Before

`@lexical/html` has one entry point, and it carries BlockIdExtension:

```
$ pnpm run build --www --prod
$ ls packages/lexical-html/dist/*.prod.js
packages/lexical-html/dist/LexicalHtml.prod.js
$ grep -c LexicalExtensionBlockIdExtension packages/lexical-html/dist/LexicalHtml.prod.js
1
$ wc -c packages/lexical-html/dist/LexicalHtml.prod.js
30463 packages/lexical-html/dist/LexicalHtml.prod.js
```

### After

The barrel no longer reaches BlockIdExtension; the opt-in entry point does:

```
$ pnpm run build --www --prod
$ ls packages/lexical-html/dist/*.prod.js
packages/lexical-html/dist/LexicalHtml.prod.js
packages/lexical-html/dist/LexicalHtmlBlockIdHTMLExtension.prod.js
$ grep -c LexicalExtensionBlockIdExtension packages/lexical-html/dist/LexicalHtml.prod.js
0
$ grep -o 'require("LexicalExtensionBlockIdExtension")' packages/lexical-html/dist/LexicalHtmlBlockIdHTMLExtension.prod.js
require("LexicalExtensionBlockIdExtension")
$ wc -c packages/lexical-html/dist/LexicalHtml.prod.js
28988 packages/lexical-html/dist/LexicalHtml.prod.js
```

Checks:

```
$ pnpm run tsc
$ pnpm run tsc-test
$ pnpm run flow
Running Flow...
Found 0 errors
$ pnpm run lint
$ pnpm run prettier
```

Unit tests for the package, and the tree-shaking suites that bundle a bare
import of every entry point (the new one included):

```
$ pnpm vitest --project unit --no-watch packages/lexical-html
 Test Files  16 passed (16)
      Tests  139 passed (139)

$ pnpm vitest --project scripts-unit --no-watch treeShaking
 ✓ |scripts-unit| packages/lexical-compiler/src/__tests__/unit/treeShaking.test.ts (6 tests)
 ✓ |scripts-unit| scripts/__tests__/unit/treeShakingSource.test.ts (346 tests)
 Test Files  2 passed (2)
      Tests  352 passed (352)
```

`pnpm run lint-flow` reports the same 63 `@lexical/html` warnings before and
after this change, and its `@lexical/yjs` failures are likewise unchanged.
E2E and browser suites were not run.
@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
lexical Ready Ready Preview Oct 28, 2026 7:01am UTC
lexical-playground Ready Ready Preview Oct 28, 2026 7:01am UTC

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 Oct 27, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
lexical

npm i https://pkg.pr.new/lexical@9474

@lexical/a11y

npm i https://pkg.pr.new/@lexical/a11y@9474

@lexical/clipboard

npm i https://pkg.pr.new/@lexical/clipboard@9474

@lexical/code

npm i https://pkg.pr.new/@lexical/code@9474

@lexical/code-core

npm i https://pkg.pr.new/@lexical/code-core@9474

@lexical/code-prism

npm i https://pkg.pr.new/@lexical/code-prism@9474

@lexical/code-shiki

npm i https://pkg.pr.new/@lexical/code-shiki@9474

@lexical/compiler

npm i https://pkg.pr.new/@lexical/compiler@9474

@lexical/devtools-core

npm i https://pkg.pr.new/@lexical/devtools-core@9474

@lexical/dragon

npm i https://pkg.pr.new/@lexical/dragon@9474

@lexical/eslint-plugin

npm i https://pkg.pr.new/@lexical/eslint-plugin@9474

@lexical/extension

npm i https://pkg.pr.new/@lexical/extension@9474

@lexical/fast-check

npm i https://pkg.pr.new/@lexical/fast-check@9474

@lexical/file

npm i https://pkg.pr.new/@lexical/file@9474

@lexical/hashtag

npm i https://pkg.pr.new/@lexical/hashtag@9474

@lexical/headless

npm i https://pkg.pr.new/@lexical/headless@9474

@lexical/history

npm i https://pkg.pr.new/@lexical/history@9474

@lexical/html

npm i https://pkg.pr.new/@lexical/html@9474

@lexical/internal

npm i https://pkg.pr.new/@lexical/internal@9474

@lexical/link

npm i https://pkg.pr.new/@lexical/link@9474

@lexical/list

npm i https://pkg.pr.new/@lexical/list@9474

@lexical/mark

npm i https://pkg.pr.new/@lexical/mark@9474

@lexical/markdown

npm i https://pkg.pr.new/@lexical/markdown@9474

@lexical/mdast

npm i https://pkg.pr.new/@lexical/mdast@9474

@lexical/offset

npm i https://pkg.pr.new/@lexical/offset@9474

@lexical/overflow

npm i https://pkg.pr.new/@lexical/overflow@9474

@lexical/plain-text

npm i https://pkg.pr.new/@lexical/plain-text@9474

@lexical/react

npm i https://pkg.pr.new/@lexical/react@9474

@lexical/rich-text

npm i https://pkg.pr.new/@lexical/rich-text@9474

@lexical/selection

npm i https://pkg.pr.new/@lexical/selection@9474

@lexical/table

npm i https://pkg.pr.new/@lexical/table@9474

@lexical/tailwind

npm i https://pkg.pr.new/@lexical/tailwind@9474

@lexical/text

npm i https://pkg.pr.new/@lexical/text@9474

@lexical/utils

npm i https://pkg.pr.new/@lexical/utils@9474

@lexical/yjs

npm i https://pkg.pr.new/@lexical/yjs@9474

commit: ed88633

…n links at its real API page

## Description

The two links added in the previous commit used the flat module id
`lexical_html_BlockIdHTMLExtension`, which does not exist: the site's
`LegacyRouter` (`src/plugins/lexical-typedoc-plugin-legacy-router`) only
flattens `@lexical/react/*` subpaths, so every other package's subpath entry
point keeps a nested page. The page typedoc emits for
`@lexical/html/BlockIdHTMLExtension` is
`docs/api/modules/lexical_html/BlockIdHTMLExtension.md`, the same shape as
the existing `lexical_extension/BlockIdExtension.md`.

Both links now use that path. No other doc links to a nested module page
today, which is why the form was easy to get wrong.

## Test plan

### Before

```
$ pnpm run build-docs
[ERROR] Error: Unable to build website for locale en.
  [cause]: Error: Docusaurus found broken links!
  Exhaustive list of all broken links found:
  - Broken link on source page path = /docs/extensions/block-ids:
     -> linking to /docs/api/modules/lexical_html_BlockIdHTMLExtension#blockidhtmlextension
  - Broken link on source page path = /docs/extensions/included-extensions:
     -> linking to /docs/api/modules/lexical_html_BlockIdHTMLExtension#blockidhtmlextension
```

### After

```
$ pnpm run build-docs
[info] markdown generated at ./docs/api
[SUCCESS] Generated static files in "build".
[INFO] Use `npm run serve` command to test your build locally.
```

The remaining `/docs/api/` HTML-minifier warnings are unchanged from `main`.
etrepum
etrepum previously approved these changes Oct 27, 2026

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it's worth fixing that update-tsconfig issue

@etrepum
etrepum dismissed their stale review October 27, 2026 16:06

Found an issue

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Codex found this:

P1 — The new entry duplicates shared HTML extensions. At package.json (line 28), the separate bundle inlines DOMImportExtension, DOMRenderExtension, and supporting context state. These differ from the objects exported by @lexical/html.

…on entry from bundling its own copy of @lexical/html

## Description

`BlockIdHTMLExtension.ts` imported `DOMImportExtension`, `DOMRenderExtension`, `ImportOverlays`, `domOverride`, `sel` and the rule factories from the modules that define them. None of those modules is a public entry, so the build bundled all of them into `LexicalHtmlBlockIdHTMLExtension.js` (61 KB in development) as a second copy of what `LexicalHtml.js` already ships. That copy defines its own `DOMImportExtension` and `DOMRenderExtension` under the same names as the barrel's, so an editor that lists `DOMImportExtension` from `@lexical/html` next to `BlockIdHTMLExtension` fails to build:

```
LexicalBuilder: Multiple extensions registered with name @lexical/html/DOMImport, names must be unique
```

and the copied `ImportOverlays` context state would not be the one the barrel's import pipeline reads.

`BlockIdHTMLExtension.ts` now imports all of these from `./index`, which `subpathImports` rewrites to `@lexical/html`, so the entry keeps them external (4.7 KB in development).

`pureAnnotations` only took evidence from a relative module's own declarations, so in source mode (the Vite plugin, the `source` condition) the calls to `sel`, `defineImportRule` and `defineOverlayRules` imported through `./index` went unannotated and a bare import of the module retained all of `@lexical/html`. It now also follows named re-exports from relative modules, which is how a package root carries them.

A new integration test loads every published entry and requires that no two distinct extension objects reachable from their exports share a name.

## Test plan

### Before

```
$ node scripts/build.mjs && vitest run scripts/__tests__/integration/subpath-imports.test.mjs -t "only one published entry"
 × defines each extension in only one published entry
AssertionError: @lexical/html/DOM from @lexical/html/BlockIdHTMLExtension and @lexical/html: expected false to be true
```

With `./index` imports but without the compiler change:

```
$ vitest run --project scripts-unit scripts/__tests__/unit/treeShakingSource.test.ts -t lexical-html
 × @lexical/html (packages/lexical-html/src/BlockIdHTMLExtension.ts)
AssertionError: expected 'var $inlineStylesFromStyleSheets = (d…' to be ''
```

### After

```
$ node scripts/build.mjs && vitest run scripts/__tests__/integration/subpath-imports.test.mjs -t "only one published entry"
 ✓ defines each extension in only one published entry
$ vitest run --project scripts-unit scripts/__tests__/unit/treeShakingSource.test.ts -t lexical-html
      Tests  25 passed | 321 skipped (346)
```

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nistically

## Description

`update-tsconfig.mjs` globs every file in a package's `src/__tests__/utils/`
and pushes each one under the same `<pkg>/src/__tests__/utils` key, so the
alias ends up pointing at whichever file the glob returned last. That is
filesystem order: `pnpm run update-tsconfig` writes `utils/index.tsx` on one
machine and `utils/assertNodeType.ts` on another, and `pnpm run tsc` then
fails wherever the entry point lost. `lexical` is the only package with more
than one file in that directory, so it is the only alias that moves — it is
what made `pnpm run update-packages` leave an unrelated broken edit in this
PR's first commit.

The alias names a directory, so it now resolves to that directory's
`index.{ts,tsx,mjs,jsx}` and nothing else. Deep imports of the other files
already resolve through the `<pkg>/src/*` alias.

## Test plan

### Before

Regenerating on Linux moves the alias off the entry point and breaks the
typecheck:

```
$ pnpm run update-tsconfig
$ git diff --stat
 tsconfig.json      | 2 +-
 tsconfig.test.json | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
$ git diff -U1 tsconfig.json
       "lexical/src/__tests__/utils": [
-        "./packages/lexical/src/__tests__/utils/index.tsx"
+        "./packages/lexical/src/__tests__/utils/assertNodeType.ts"
       ],
$ pnpm run tsc
packages/lexical/src/__tests__/unit/LexicalListPlugin.test.tsx(29,3): error TS2305: Module '"lexical/src/__tests__/utils"' has no exported member 'TestComposer'.
packages/lexical/src/__tests__/unit/LexicalReconcilerStaleDecorator.test.ts(20,3): error TS2305: Module '"lexical/src/__tests__/utils"' has no exported member '$createTestDecoratorNode'.
packages/lexical/src/__tests__/unit/LexicalReconcilerStaleDecorator.test.ts(21,3): error TS2305: Module '"lexical/src/__tests__/utils"' has no exported member 'TestDecoratorNode'.
[ELIFECYCLE] Command failed with exit code 2.
```

### After

Regenerating reproduces the committed tsconfigs exactly, and the checks pass:

```
$ pnpm run update-tsconfig
$ git diff --stat -- tsconfig.json tsconfig.test.json packages/lexical-website/tsconfig.json packages/lexical-devtools/tsconfig.json
$ pnpm run tsc
$ pnpm run tsc-test
$ pnpm run tsc-scripts
$ pnpm run lint
$ pnpm run prettier
$ git status --short
 M scripts/update-tsconfig.mjs
```
@potatowagon

Copy link
Copy Markdown
Contributor Author

Both points are addressed.

update-tsconfig — 836aff9. The script globbed every file in a package's src/__tests__/utils/ and pushed them all under the same <pkg>/src/__tests__/utils key, so the alias pointed at whichever file glob returned last, i.e. filesystem order: index.tsx on one machine, assertNodeType.ts on another. It now resolves the directory's index.{ts,tsx,mjs,jsx}; deep imports of the other files already go through <pkg>/src/*. pnpm run update-tsconfig is now a no-op against the committed tsconfigs, and tsc, tsc-test, tsc-scripts, lint and prettier all pass.

Codex P1 (duplicated HTML extensions) — 36a7864. BlockIdHTMLExtension.ts now imports DOMImportExtension, DOMRenderExtension, ImportOverlays, domOverride, sel and the rule factories through ./index, which subpathImports rewrites to @lexical/html, so the entry keeps them external instead of shipping a second copy (61 KB → 4.7 KB in development). pureAnnotations now follows named re-exports from relative modules so the source-mode tree-shaking test still passes, and a new integration test fails if two published entries define extensions under the same name.

## Description

No code change. GitHub created no Actions check suite at all for 836aff9
— neither the `synchronize` push nor a close/reopen produced one, while
other pull requests in the repository ran normally throughout — so this
empty commit re-fires the workflows.
Conflict in `scripts/update-tsconfig.mjs`: meta#9482 landed the same index-only
fix for the bare `<pkg>/src/__tests__/utils` alias on main, so this takes
main's version and drops the one from 836aff9.
@potatowagon
potatowagon added this pull request to the merge queue Oct 28, 2026
Merged via the queue into meta:main with commit 72a7d15 Oct 28, 2026
46 checks passed
zurfyx added a commit that referenced this pull request Oct 28, 2026
…hangeset at the @lexical/html/BlockIdHTMLExtension entry point

## Description

#9474 moved `BlockIdHTMLExtension` out of the `@lexical/html` barrel into
its own entry point. Both changes are unreleased, so v0.53.0 users only ever
see the new import path: this updates the #9421 changeset to name it rather
than adding a breaking entry.

## Test plan

### After

```
$ pnpm run check-changesets
Changeset check passed: 55 pending changeset(s) valid.
```
@zurfyx zurfyx mentioned this pull request Oct 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — ed886335 Deployed Oct 28, 2026 by vercel[bot]
Preview – lexical-playground — ed886335 Deployed Oct 28, 2026 by vercel[bot]
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants