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

[Breaking Change][*] Chore: Use terser for optimizing cjs prod build #7047

Merged
merged 7 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/size-limit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,75 @@ jobs:
env:
CI_JOB_NUMBER: 1
steps:
# See also:
# https://github.com/facebook/lexical/issues/6852
# https://github.com/NixOS/nixpkgs/blob/c8db8bd9656ee3d373ce9445063c25c47f442118/.github/workflows/check-by-name.yml#L31-L92
# https://github.com/getsentry/sentry/issues/22432
# https://github.com/getsentry/sentry/pull/22344
# This step has to be in this file,
# because it's needed to determine which revision of the repository to fetch,
# and we can only use other files from the repository once it's fetched.
- id: merge-commit
name: Resolving the merge commit
env:
GH_TOKEN: ${{ github.token }}
run: |
# This checks for mergeability of a pull request as recommended in
# https://docs.github.com/en/rest/guides/using-the-rest-api-to-interact-with-your-git-database?apiVersion=2022-11-28#checking-mergeability-of-pull-requests

# Retry the API query this many times
retryCount=3
# Start with 5 seconds, but double every retry
retryInterval=5
while true; do
echo "Checking whether the pull request can be merged"
prInfo=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/"$GITHUB_REPOSITORY"/pulls/${{ github.event.pull_request.number }})
mergeable=$(jq -r .mergeable <<< "$prInfo")
mergedSha=$(jq -r .merge_commit_sha <<< "$prInfo")

if [[ "$mergeable" == "null" ]]; then
if (( retryCount == 0 )); then
echo "Not retrying anymore, probably GitHub is having internal issues"
exit 1
else
(( retryCount -= 1 )) || true

# null indicates that GitHub is still computing whether it's mergeable
# Wait a couple seconds before trying again
echo "GitHub is still computing whether this PR can be merged, waiting $retryInterval seconds before trying again ($retryCount retries left)"
sleep "$retryInterval"

(( retryInterval *= 2 )) || true
fi
else
break
fi
done

if [[ "$mergeable" == "true" ]]; then
echo "The PR can be merged, checking the merge commit $mergedSha"
else
echo "The PR cannot be merged, it has a merge conflict, cancelling the workflow.."
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/"$GITHUB_REPOSITORY"/actions/runs/"$GITHUB_RUN_ID"/cancel
sleep 60
# If it's still not canceled after a minute, something probably went wrong, just exit
exit 1
fi
echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
with:
# pull_request_target checks out the base branch by default
ref: ${{ steps.merge-commit.outputs.mergedSha }}
# Fetches the merge commit and its parents
fetch-depth: 2
- uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build-prod
7 changes: 2 additions & 5 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ const path = require('node:path');
* Looks like:
*
* {
* lexical: 'packages/lexical/dist/index.js',
* '@lexical/rich-text': 'packages/lexical-rich-text/dist/index.js',
* lexical: 'packages/lexical/dist/Lexical.js',
* '@lexical/rich-text': 'packages/lexical-rich-text/dist/LexicalRichText.js',
* }
*
* Currently this alias map points at the cjs version of the build product,
* as that is what was measured previously in #3600.
*/
const {packagesManager} = require('./scripts/shared/packagesManager');
const getAliasType = (type) =>
Expand Down
234 changes: 0 additions & 234 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
"size": "npm run build-prod && size-limit"
},
"devDependencies": {
"@ampproject/rollup-plugin-closure-compiler": "^0.27.0",
"@babel/core": "^7.24.5",
"@babel/eslint-parser": "^7.24.5",
"@babel/plugin-transform-optional-catch-binding": "^7.24.1",
Expand Down
Loading
Loading