|
| 1 | +--- |
| 2 | +name: react-upgrade |
| 3 | +description: "Drive the current react-server-dom-webpack upgrade flow using scripts/react-upgrade/upgrade.js and the React fork cherry-pick workflow." |
| 4 | +argument-hint: '<target-version> <react-fork-path> [--dry-run|--reset-branch|--rebuild-only] | --continue [<target-version> <react-fork-path>]' |
| 5 | +--- |
| 6 | + |
| 7 | +# React Upgrade |
| 8 | + |
| 9 | +Use this skill when upgrading the vendored `react-server-dom-webpack` runtime |
| 10 | +artifacts in `src/react-server-dom-webpack/`. |
| 11 | + |
| 12 | +## Current Rule |
| 13 | + |
| 14 | +Never hand-edit `src/react-server-dom-webpack/`. The current supported flow is |
| 15 | +the cherry-pick based script in `scripts/react-upgrade/upgrade.js`. |
| 16 | + |
| 17 | +Read `docs/eliminate-react-fork.md` before changing the upgrade strategy. That |
| 18 | +document describes the planned patch-file future, but the current script still |
| 19 | +uses a local React fork. |
| 20 | + |
| 21 | +Transition note: patch-file or stock-React tooling is planned after #60/#71. |
| 22 | +Until those issues land in this repo, do not invent patch directories, stock |
| 23 | +React clone behavior, or completed replacement tooling. |
| 24 | + |
| 25 | +## Prerequisites |
| 26 | + |
| 27 | +- A local clone of the React fork that contains `rsc-patches/v<version>` |
| 28 | + branches and upstream `v<version>` tags. |
| 29 | +- Dependencies installed for the upgrade helper: |
| 30 | + ```bash |
| 31 | + cd scripts/react-upgrade |
| 32 | + yarn install |
| 33 | + ``` |
| 34 | +- Dependencies installed in the React fork so it can build |
| 35 | + `react-server-dom-webpack`. |
| 36 | + |
| 37 | +## Commands |
| 38 | + |
| 39 | +From the repository root, pass the React fork as an absolute path. The current |
| 40 | +script resolves relative `reactForkPath` values from `scripts/react-upgrade/`, |
| 41 | +not from the caller's current directory. |
| 42 | + |
| 43 | +```bash |
| 44 | +REACT_FORK="$(cd <reactForkPath> && pwd)" |
| 45 | +node scripts/react-upgrade/upgrade.js <targetVersion> "$REACT_FORK" --dry-run |
| 46 | +node scripts/react-upgrade/upgrade.js <targetVersion> "$REACT_FORK" |
| 47 | +``` |
| 48 | + |
| 49 | +Useful options: |
| 50 | + |
| 51 | +```bash |
| 52 | +node scripts/react-upgrade/upgrade.js --continue # resume interrupted upgrade; reads version/fork from .upgrade-state.json |
| 53 | +node scripts/react-upgrade/upgrade.js <targetVersion> "$REACT_FORK" --continue # resume and override recorded version/fork |
| 54 | +node scripts/react-upgrade/upgrade.js <targetVersion> "$REACT_FORK" --reset-branch |
| 55 | +node scripts/react-upgrade/upgrade.js <targetVersion> "$REACT_FORK" --rebuild-only |
| 56 | +``` |
| 57 | + |
| 58 | +Option meanings: |
| 59 | + |
| 60 | +- `--continue` without arguments resumes from `.upgrade-state.json`. |
| 61 | +- `--continue` with `targetVersion` and `REACT_FORK` resumes while overriding |
| 62 | + the recorded version and fork path. |
| 63 | +- `--reset-branch` deletes and recreates the target patch branch in the React |
| 64 | + fork. Use it only when intentionally discarding unresolved patch-branch work. |
| 65 | +- `--rebuild-only` skips cherry-picking and rebuilds/copies artifacts from the |
| 66 | + existing patch branch. |
| 67 | + |
| 68 | +## What The Script Does |
| 69 | + |
| 70 | +1. Creates or checks out `rsc-patches/v<targetVersion>` in the React fork from |
| 71 | + the upstream `v<targetVersion>` tag. |
| 72 | +2. Finds the closest prior `rsc-patches/v...` source branch. |
| 73 | +3. Cherry-picks `[RSC-PATCH]` commits into the React fork branch. |
| 74 | +4. Builds `react-server-dom-webpack/ --releaseChannel stable` in the React fork. |
| 75 | +5. Copies built artifacts into this repo's `src/react-server-dom-webpack/`. |
| 76 | +6. Syncs package metadata. |
| 77 | +7. Commits copied artifacts with |
| 78 | + `Update react-server-dom-webpack to React <targetVersion>`. |
| 79 | +8. Cherry-picks the most recent consecutive `[RSC-REPLACE]` commits in this |
| 80 | + repo and checks for remaining standalone replacement strings. |
| 81 | + |
| 82 | +## Conflict Handling |
| 83 | + |
| 84 | +- React fork patch conflicts: resolve in the React fork, run |
| 85 | + `git cherry-pick --continue`, then resume with `node scripts/react-upgrade/upgrade.js --continue`. |
| 86 | +- Replacement conflicts in this repo: resolve the conflicting files, stage them, |
| 87 | + then continue when the script prompts. |
| 88 | +- If `.upgrade-state.json` exists, prefer `--continue` over deleting state. |
| 89 | + |
| 90 | +## Validation |
| 91 | + |
| 92 | +After an upgrade changes generated runtime artifacts, run the checks that cover |
| 93 | +the changed surface: |
| 94 | + |
| 95 | +```bash |
| 96 | +yarn build |
| 97 | +yarn test |
| 98 | +``` |
| 99 | + |
| 100 | +If e2e scripts have landed, also run `$run-e2e` for the relevant bundler lanes |
| 101 | +and `$downstream-e2e` when validating downstream compatibility. |
| 102 | + |
| 103 | +For changes to the upgrade helper itself, also run: |
| 104 | + |
| 105 | +```bash |
| 106 | +cd scripts/react-upgrade |
| 107 | +node --test lib/*.test.js |
| 108 | +``` |
0 commit comments