Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Refactor: move error-codes generation to existing babel plugin #6005

Merged
merged 2 commits into from
May 10, 2024

Conversation

etrepum
Copy link
Collaborator

@etrepum etrepum commented May 2, 2024

Description

Previously we had a rollup plugin and separate a babel plugin for managing error codes, which are a map of sequential integers to error message strings that are used in minified prod builds so that we are not shipping verbose error message strings.

Both plugins essentially did the same work, but the updating of the map was only done in the rollup plugin. This consolidates all of the functionality to the babel plugin which is now able to conditionally update the error map if the --codes argument was present.

This PR also updates the postversion script to ensure that codes are generated before a release and ensures that the versions and package-lock.json are updated accordingly.

Code extraction is now integrated into npm run build-release (which is a dependency of npm run prepare-release and npm run release) as a failsafe to ensure codes are updated before release.

I chose not to update the filename for codes.json in this PR. I think we can do that separately in a follow-up to address the concern that the filename should let people know that it is generated. I think we should do a release with this first before changing too many more things.

Test plan

Before

npm run error-codes was supposedly in a state where it no longer worked (re #5996)

It was also easy to forget to do this before creating a release, which would leave error messages unextracted (larger prod build).

After

npm run increment-version and npm run build-release (and anything downstream such as npm run prepare-release or npm run release) will generate the scripts/error-codes/codes.json file.

The new unit tests should also pass!

Copy link

vercel bot commented May 2, 2024

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 May 4, 2024 2:57pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2024 2:57pm

…abel plugin and always run with build-release
@etrepum
Copy link
Collaborator Author

etrepum commented May 10, 2024

@ivailop7 this one would be nice to have in the release as well, especially if there is some issue running extract-codes without it

@ivailop7
Copy link
Collaborator

@etrepum do you need to rebase this one before we merge?

@acywatson
Copy link
Contributor

@etrepum do you need to rebase this one before we merge?

I don't see any conflicts flagged by github here...

@ivailop7 ivailop7 merged commit 555efea into facebook:main May 10, 2024
46 checks passed
@etrepum etrepum deleted the extract-errors-fix branch May 11, 2024 06:46
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.

4 participants