Skip to content

fix: upgrade Vite to v8 + enable React Compiler#5657

Draft
cuzz-venus wants to merge 1 commit into
mainfrom
fix/react-compiler-form-watch
Draft

fix: upgrade Vite to v8 + enable React Compiler#5657
cuzz-venus wants to merge 1 commit into
mainfrom
fix/react-compiler-form-watch

Conversation

@cuzz-venus

@cuzz-venus cuzz-venus commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Jira ticket(s)

VPD-1406

Changes

  • upgrade Vite to v8
  • enable React Compiler

@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 75b4115

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dapp-preview Ready Ready Preview Jun 24, 2026 12:34pm
dapp-testnet Ready Ready Preview Jun 24, 2026 12:34pm
venus.io Ready Ready Preview Jun 24, 2026 12:34pm

Request Review

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 81.96% 48768 / 59502
🔵 Statements 81.96% 48768 / 59502
🔵 Functions 62.71% 671 / 1070
🔵 Branches 72.99% 5538 / 7587
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/evm/src/index.tsx 0% 100% 100% 0% 2-17
apps/evm/src/components/Icon/icons/index.ts 99.03% 0% 100% 99.03% 1
apps/evm/src/containers/Layout/index.tsx 0% 0% 0% 0% 1-92
apps/evm/src/containers/Layout/store.ts 0% 0% 0% 0% 1-15
apps/evm/src/containers/Layout/NavBar/Settings/GaslessTransactionSetting/index.tsx 0% 0% 0% 0% 1-46
apps/evm/src/containers/Layout/ScrollToTop/index.tsx 0% 0% 0% 0% 1-28
apps/evm/src/containers/ResendPayingGasModal/index.tsx 0% 0% 0% 0% 1-12
apps/evm/src/containers/ResendPayingGasModal/Modal/index.tsx 0% 0% 0% 0% 1-67
apps/evm/src/containers/ResendPayingGasModal/store/index.ts 83.33% 0% 0% 83.33% 1
apps/evm/src/containers/VaultCard/InstitutionalVaultModal/PositionTab/DepositForm/index.tsx 98.85% 40% 100% 98.85% 39
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/DepositForm/index.tsx 100% 66.66% 100% 100%
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/WithdrawForm/index.tsx 96.29% 63.63% 100% 96.29% 93, 129-134
apps/evm/src/containers/VaultForm/index.tsx 94.78% 93.18% 75% 94.78% 176-185, 211-212
apps/evm/src/containers/VenusVaultModal/StakeForm/index.tsx 100% 90.9% 100% 100%
apps/evm/src/containers/VenusVaultModal/WithdrawTab/WithdrawFromVaiVaultForm/index.tsx 100% 60% 100% 100%
apps/evm/src/containers/VenusVaultModal/WithdrawTab/WithdrawFromVestingVaultForm/RequestWithdrawalForm/index.tsx 97.75% 84% 100% 97.75% 57-58, 72-73
apps/evm/src/hooks/useSendTransaction/index.ts 90.56% 80.76% 50% 90.56% 5, 126-129, 161, 169, 195-197
apps/evm/src/hooks/useUserChainSettings/index.tsx 93.54% 60% 100% 93.54% 1, 26
apps/evm/src/libs/notifications/NotificationCenter/index.tsx 98.38% 62.5% 100% 98.38% 31
apps/evm/src/libs/notifications/store/index.ts 96.77% 90% 100% 96.77% 1
apps/evm/src/libs/notifications/utilities/index.ts 97.43% 83.33% 100% 97.43% 1
apps/evm/src/pages/Bridge/index.tsx 91.9% 84.28% 81.81% 91.9% 80, 134-135, 166-168, 174-186, 212-214, 240-242, 249-251, 281, 344-346
apps/evm/src/pages/Bridge/useBridgeForm.ts 94.33% 75.6% 100% 94.33% 1, 90, 215-224, 292-293
apps/evm/src/pages/Dashboard/Guide/index.tsx 79% 62.5% 0% 79% 47-48, 53-58, 90-104
apps/evm/src/pages/Dashboard/Overview/index.tsx 97.27% 75% 66.66% 97.27% 196, 227, 231, 262, 271-274
apps/evm/src/pages/Trade/index.tsx 94.4% 90.32% 66.66% 94.4% 65-73
apps/evm/src/pages/Trade/Banner/index.tsx 0% 0% 0% 0% 1-46
apps/evm/src/pages/Trade/Banner/store/index.ts 95% 75% 100% 95% 1
apps/evm/src/pages/Trade/ClosePositionModal/index.tsx 100% 75% 100% 100%
apps/evm/src/pages/Trade/ClosePositionModal/Form/index.tsx 0% 0% 0% 0% 1-22
apps/evm/src/pages/Trade/ClosePositionModal/store/index.ts 92.85% 66.66% 100% 92.85% 1
apps/evm/src/pages/Trade/PairInfo/index.tsx 95.9% 75% 100% 95.9% 148-149, 158-161, 194, 201
apps/evm/src/pages/Trade/Positions/PositionList/index.tsx 100% 93.33% 100% 100%
apps/evm/src/pages/Trade/ReduceForm/index.tsx 98.29% 96.34% 100% 98.29% 77, 322-325
apps/evm/src/pages/Vai/Borrow/index.tsx 95.08% 84.09% 100% 95.08% 62, 85-86, 101, 111, 199-203, 220-221
apps/evm/src/pages/Vai/Repay/index.tsx 94.55% 52.94% 100% 94.55% 60-61, 127-131, 154-155, 163-165
apps/evm/src/store/index.ts 98.3% 88.88% 100% 98.3% 1
apps/evm/src/utilities/index.ts 98.64% 0% 100% 98.64% 1
Generated in workflow #13716 for commit 75b4115 by the Vitest Coverage Report Action

@therealemjy therealemjy force-pushed the fix/react-compiler-form-watch branch from 5cff30a to 75b4115 Compare June 24, 2026 12:32
@therealemjy therealemjy changed the title fix: react compile watch bugs fix: upgrade Vite to v8 + enable React Compiler Jun 24, 2026
@therealemjy therealemjy marked this pull request as ready for review June 24, 2026 12:32
@therealemjy

Copy link
Copy Markdown
Member

@greptile

@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR upgrades Vite from v6 to v8, enables the React Compiler via @vitejs/plugin-react v6 + @rolldown/plugin-babel, and performs the required code modernisation to make the compiler happy (replacing form.watch() with useWatch(), removing the createStoreSelectors abstraction in favour of direct useStore(state => state.xxx) selectors, and renaming the reserved-keyword switch icon to swap).

  • React Compiler integration: enabled in production builds with compilationMode: 'infer' and panicThreshold: 'none' (skips rather than crashes on uncompilable components); disabled in test mode to avoid impacting test performance.
  • Store refactor: createStoreSelectors and the store.use.xxx() accessor pattern are removed across all Zustand stores; consumers now use explicit selector functions, which are both simpler and React Compiler-friendly.
  • Buffer polyfill: build-time injection via @rollup/plugin-inject is replaced with a runtime globalThis.Buffer ??= Buffer assignment in index.tsx; the ordering relative to module evaluation deserves a quick verification pass against wallet-SDK dependencies.

Confidence Score: 4/5

Safe to merge after confirming no wallet-SDK dependency reads Buffer as a global during module initialisation, and verifying the isLoading addition in StakeForm is intentional.

The store refactor and form-watch migration are thorough and consistent across the codebase. The only non-trivial risks are: (1) the Buffer polyfill is now set after all module side-effects execute, which could silently break a dependency that accesses the global early; and (2) isLoading is now forwarded to VaultForm from StakeForm without explanation, changing button behaviour in a PR ostensibly about tooling. Neither is a definitive bug, but both deserve a quick confirmation before shipping to production.

apps/evm/src/index.tsx (Buffer global ordering), apps/evm/src/containers/VenusVaultModal/StakeForm/index.tsx (isLoading addition)

Important Files Changed

Filename Overview
apps/evm/vite.config.mts Upgrades Vite to v8, enables React Compiler via @rolldown/plugin-babel with reactCompilerPreset, adds jsxImportSource for emotion, and removes the build-time Buffer injection plugin
apps/evm/src/index.tsx Replaces build-time Buffer injection (via @rollup/plugin-inject) with a runtime globalThis.Buffer ??= Buffer assignment; sets global after all module imports are evaluated
apps/evm/src/utilities/createStoreSelectors.ts Deleted — the createStoreSelectors utility is removed; all stores now export useStore directly and consumers use useStore(state => state.xxx) selectors
apps/evm/src/store/index.ts Exports useStore directly instead of wrapping with createStoreSelectors; removes the store.use.xxx() accessor pattern
apps/evm/src/pages/Bridge/useBridgeForm.ts Replaces form.watch() spread with individual useWatch() calls per field; explicitly returns fromChainId and toChainId from the hook so Bridge/index.tsx no longer needs to call watch()
apps/evm/src/containers/VenusVaultModal/StakeForm/index.tsx Replaces form.watch() with useWatch() and additionally extracts isLoading from useStakeInVault() to pass it to VaultForm — this is a behavioral change bundled with the React Compiler migration
apps/evm/src/components/Icon/icons/swap.tsx Renames the switch.tsx icon to swap.tsx — avoids using a JavaScript reserved word as an export name, which is required for React Compiler compatibility
apps/evm/src/libs/notifications/utilities/index.ts Updates all store.getState() calls to use useStore.getState() after the store rename; logic is unchanged
apps/evm/package.json Upgrades vite (^6 → ^8), @vitejs/plugin-react (^4 → ^6), replaces @rollup/plugin-inject with @rolldown/plugin-babel, adds babel-plugin-react-compiler and @babel/core

Reviews (1): Last reviewed commit: "feat: upgrade Vite to v8 and enable Reac..." | Re-trigger Greptile

Comment thread apps/evm/src/index.tsx
Comment on lines +81 to 85
const fromAmountTokensFieldValue = useWatch({ control: form.control, name: 'fromAmountTokens' });
const fromAmountTokens = new BigNumber(fromAmountTokensFieldValue || 0);

const { stake } = useStakeInVault();
const { stake, isLoading } = useStakeInVault();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Unrelated behavioral change bundled into infrastructure PR

isLoading is now destructured from useStakeInVault() and forwarded to VaultForm. This is a functional change — if VaultForm uses isLoading to disable or show a spinner on the submit button, this changes the button's behaviour during staking. This appears unrelated to the Vite v8 / React Compiler migration and is not reflected in the PR description. Was this intentional? Is extracting isLoading from useStakeInVault and passing it to VaultForm intentional? It changes stake-button behaviour and seems unrelated to the Vite/React Compiler upgrade.

@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR upgrades Vite from v6 to v8 (switching the bundler core to Rolldown) and enables the React Compiler for production builds. Alongside the tooling change, it removes the createStoreSelectors helper (replacing all store.use.xxx() calls with standard useStore(state => state.xxx) selectors) and migrates every form.watch() call to the useWatch() hook so the React Compiler can properly track reactive dependencies.

  • Vite 8 / Rolldown migration: @rollup/plugin-inject is removed; the Buffer polyfill moves to a manual globalThis.Buffer ??= Buffer in index.tsx. @vitejs/plugin-react is upgraded to v6 and paired with @rolldown/plugin-babel + babel-plugin-react-compiler for the React Compiler pass (disabled in test mode via mode === 'test', limited to apps/evm/src/** via a Rolldown filter).
  • Store pattern cleanup: createStoreSelectors and its .use.xxx() accessor pattern are deleted; all six store files now export useStore directly and every consumer is updated to explicit selectors.
  • React-hook-form migration: All form.watch()/watch() usages across vault, bridge, and VAI forms are replaced with useWatch({ control, name }) for React Compiler compatibility. useBridgeForm now returns fromChainId and toChainId as explicit properties instead of relying on the caller to call watch().
  • Icon rename: switch.tsx (reserved word) is renamed to swap.tsx and all references updated.

Confidence Score: 4/5

Safe to merge — the migrations are mechanical and complete, no regressions found in the store or form-watch patterns.

The store selector migration and form.watch to useWatch migration are done consistently across all 55 files with no leftover old-pattern calls. Two non-blocking observations in vite.config.mts: the reactCompilerPreset filter is applied by mutating the preset object after creation, and jsxImportSource is now global instead of opt-in per file.

apps/evm/vite.config.mts — React Compiler filter mutation and global jsxImportSource change are worth a second look.

Important Files Changed

Filename Overview
apps/evm/vite.config.mts Upgrades Vite to v8, replaces @rollup/plugin-inject with @rolldown/plugin-babel for the React Compiler, enables reactCompilerPreset with file filter and panicThreshold:'none'. Adds jsxImportSource:'@emotion/react' globally.
apps/evm/package.json Bumps vite to ^8.0.16, @vitejs/plugin-react to ^6.0.2; adds @babel/core, @rolldown/plugin-babel, babel-plugin-react-compiler; removes @rollup/plugin-inject.
apps/evm/src/index.tsx Buffer is now manually polyfilled via globalThis.Buffer at app entry instead of via the removed @rollup/plugin-inject plugin; approach is correct.
apps/evm/src/utilities/createStoreSelectors.ts File deleted — the createStoreSelectors helper (store.use.xxx() pattern) is removed. All consumers updated to use direct useStore(state => state.xxx) selectors.
apps/evm/src/store/index.ts Removes createStoreSelectors wrapper and exports useStore directly instead of the selector-enhanced store object. All consumers updated.
apps/evm/src/pages/Bridge/useBridgeForm.ts Replaces form.watch() with three separate useWatch() calls and explicitly returns fromChainId and toChainId from the hook. Consumer updated accordingly.
apps/evm/src/libs/notifications/utilities/index.ts All four store.getState() calls updated from the removed selector-enhanced store to useStore.getState(). Functionally equivalent.
apps/evm/src/containers/VenusVaultModal/StakeForm/index.tsx Replaces form.watch() with useWatch(); also now passes isLoading from useStakeInVault() to VaultForm (previously omitted).
apps/evm/src/components/Icon/icons/swap.tsx New file: replaces switch.tsx (reserved keyword name) with swap.tsx, same SVG path, used in PairInfo component via Icon name="swap".

Reviews (2): Last reviewed commit: "feat: upgrade Vite to v8 and enable Reac..." | Re-trigger Greptile

Comment thread apps/evm/vite.config.mts
Comment on lines +14 to +25
const isTest = mode === 'test';
const reactCompiler = isTest
? undefined
: reactCompilerPreset({
compilationMode: 'infer',
panicThreshold: 'none',
});

if (reactCompiler) {
reactCompiler.rolldown.filter ??= {};
reactCompiler.rolldown.filter.id = {
include: ['**/apps/evm/src/**'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Mutating reactCompiler preset object after construction

reactCompilerPreset returns a preset object and this code immediately mutates its .rolldown.filter.id property to apply file-scope filtering. If the reactCompilerPreset API in a future patch release changes the shape of the returned object (e.g., renames .rolldown), this silent mutation would silently stop filtering (compiling all files including packages) rather than throw. Consider checking whether reactCompilerPreset accepts filter/include options directly as constructor arguments so the filter is part of the initial configuration rather than a post-hoc mutation.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread apps/evm/vite.config.mts
Comment on lines +33 to +36
react({
jsxImportSource: '@emotion/react',
}),
...(reactCompiler

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Global jsxImportSource changes JSX runtime for all files

Setting jsxImportSource: '@emotion/react' on the React plugin applies Emotion's JSX runtime to every file in the build, even those that don't use the css prop. Previously, files that needed Emotion's jsx function opted in with the /** @jsxImportSource @emotion/react */ pragma (e.g. ActiveVotingProgress, ApprovalSteps). Those pragmas are now redundant but harmless. The behaviour change to be aware of is that every JSX element now goes through Emotion's jsx wrapper, adding a small runtime overhead that didn't exist before for the majority of components that never use the css prop.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@therealemjy therealemjy marked this pull request as draft June 24, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants