Skip to content

Commit

Permalink
[Breaking Change][*] Chore: Use terser for optimizing cjs prod build (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum authored Jan 14, 2025
1 parent 8bd22d5 commit c8f27ed
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 261 deletions.
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

0 comments on commit c8f27ed

Please sign in to comment.