Repository navigation
[lexical-html][lexical-website] Breaking change: give BlockIdHTMLExtension its own entry point - #9474
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
lexical
@lexical/a11y
@lexical/clipboard
@lexical/code
@lexical/code-core
@lexical/code-prism
@lexical/code-shiki
@lexical/compiler
@lexical/devtools-core
@lexical/dragon
@lexical/eslint-plugin
@lexical/extension
@lexical/fast-check
@lexical/file
@lexical/hashtag
@lexical/headless
@lexical/history
@lexical/html
@lexical/internal
@lexical/link
@lexical/list
@lexical/mark
@lexical/markdown
@lexical/mdast
@lexical/offset
@lexical/overflow
@lexical/plain-text
@lexical/react
@lexical/rich-text
@lexical/selection
@lexical/table
@lexical/tailwind
@lexical/text
@lexical/utils
@lexical/yjs
commit: |
…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
left a comment
There was a problem hiding this comment.
I think it's worth fixing that update-tsconfig issue
etrepum
left a comment
There was a problem hiding this comment.
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
```
|
Both points are addressed.
Codex P1 (duplicated HTML extensions) — 36a7864. |
## 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.
…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. ```
Description
@lexical/htmlis a single-entry package, so its barrel is the unit ofinclusion for anything that consumes the built bundle rather than the source.
Since #9421 that barrel re-exports
BlockIdHTMLExtension, and that moduleimports
BlockIdExtensionfrom@lexical/extensionat module scope. Everyapp that uses
$generateHtmlFromNodes, the DOM import pipeline, or anythingelse in
@lexical/htmltherefore 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/htmla two-entry package, the way@lexical/extensionalready is:
@lexical/html— everything it exported before, less the three BlockIdHTML symbols.
@lexical/html/BlockIdHTMLExtension—BlockIdHTMLExtension,BlockIdHTMLConfigandBLOCK_ID_ATTRIBUTE.updateVersion.mjsderivesexportsfrom the top-level files ofsrc/, sodropping
mainon its own would have made every internal module a publicsubpath. Following the rule in AGENTS.md — "Helpers with only one owning
entry live under
src/internaland are bundled into that entry, withoutexposing additional public subpaths" — the eight internal modules move to
src/internal/, leaving exactlyindex.tsandBlockIdHTMLExtension.tsasentry 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'becomesimport {BlockIdHTMLExtension} from '@lexical/html/BlockIdHTMLExtension'.Unrelated, but worth knowing:
pnpm run update-tsconfigalso wants torewrite the
lexical/src/__tests__/utilspath toassertNodeType.ts, whichmakes
pnpm run tscfail. That line is left as it is onmain.Test plan
Before
@lexical/htmlhas one entry point, and it carries BlockIdExtension:After
The barrel no longer reaches BlockIdExtension; the opt-in entry point does:
Checks:
Unit tests for the package, and the tree-shaking suites that bundle a bare
import of every entry point (the new one included):
pnpm run lint-flowreports the same 63@lexical/htmlwarnings before andafter this change, and its
@lexical/yjsfailures are likewise unchanged.E2E and browser suites were not run.