Skip to content

[lexical] Feature: Add version identifier to LexicalEditor constructor - #6488

Merged
etrepum merged 9 commits into
meta:mainfrom
etrepum:version-identifier
Aug 6, 2024
Merged

etrepum merged 9 commits into
meta:mainfrom
etrepum:version-identifier

Conversation

@etrepum

@etrepum etrepum commented Aug 3, 2024 •

Copy link
Copy Markdown
Collaborator

Description

New LexicalEditor.version static to help users diagnose installation issues.

Also refactors other __lexicalEditor code to avoid conflicts with multiple lexical builds on the page (RE #6481)

Inspecting the lexical editor's version can be done as follows (example assumes exactly one editor on the page):

> document.querySelector('[contenteditable]').__lexicalEditor.constructor.version
'0.17.0+dev.esm'

It does not have support for coming up with special build identifiers for the versions of lexical we build in CI and for the website that do not correspond to npm versions.

Closes #6145
Closes #5996

Test plan

There's an integration test that checks to make sure the version is set and accessible from the editor instance

Before

> oldLexical.createEditor().constructor.version
undefined
> lexical.createEditor().constructor.version
'0.17.0+dev.esm'

After

Using https://lexical-playground-git-fork-etrepum-version-a6c103-fbopensource.vercel.app/esm/

Screenshot 2024-08-03 at 4 08 56 PM

@vercel

vercel Bot commented Aug 3, 2024 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2024 7:30pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2024 7:30pm

@facebook-github-bot facebook-github-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 Aug 3, 2024
@github-actions

github-actions Bot commented Aug 3, 2024 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
lexical - cjs 29.02 KB (0%)
lexical - esm 28.85 KB (0%)
@lexical/rich-text - cjs 37.37 KB (0%)
@lexical/rich-text - esm 28.34 KB (0%)
@lexical/plain-text - cjs 36.03 KB (0%)
@lexical/plain-text - esm 25.6 KB (0%)
@lexical/react - cjs 39.27 KB (0%)
@lexical/react - esm 29.75 KB (0%)

Comment thread packages/lexical/src/LexicalUpdates.ts Resolved
@etrepum

etrepum commented Aug 4, 2024

Copy link
Copy Markdown
Collaborator Author

I think these are flaky collab test failures

will be called immediately with an updateTag of 'registerMutationListener' where all
nodes have the 'created' NodeMutation. This can be controlled with the skipInitialization option
(default is currently true for backwards compatibility in 0.16.x but will change to false in 0.17.0).
(default is currently true for backwards compatibility in 0.17.x but will change to false in 0.18.0).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed the deprecation policy here since 0.17.0 was the first release with the changes to registerMutationListener (#6357)

},
{
from: 'process.env.LEXICAL_VERSION',
to: JSON.stringify(`${process.env.npm_package_version}+git`),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The playground is never built with an npm release of lexical since it directly includes all of the source

@potatowagon potatowagon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@etrepum
etrepum added this pull request to the merge queue Aug 6, 2024
Merged via the queue into meta:main with commit 20e4ea1 Aug 6, 2024
@etrepum
etrepum deleted the version-identifier branch August 6, 2024 18:20
return activeEditor;
}

function collectBuildInformation(): string {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@etrepum nitpicking but such detailed error is something I'd consider gating under the __DEV__ build or developer extension. I don't think it's very common to have multiple editors on the same page and it's less common to make this mistake, and there is quite some logic in here 679 bytes minimized.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Given the amount of bug reports for this one issue I was motivated to include it, I think a lot of people end up with the prod build for various reasons. You could put it behind a flag so it doesn't get included in www? Once dev tools gets a release with this functionality we could stub the implementation out with a string that says to install the dev tools to diagnose. We are still talking about <1kb before compression.

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 4071b637 Deployed Aug 5, 2024 by vercel[bot]
Preview – lexical — 4071b637 Deployed Aug 5, 2024 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. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add version/build identifier to LexicalEditor

4 participants