Skip to content

Commit 882fd94

Browse files
sirtimidclaude
andauthored
chore: migrate from Vite v7 to v8 (Rolldown/Oxc) (#919)
## Summary Vite 8 replaces Rollup+esbuild with Rolldown+Oxc as its bundler and transformer. This PR adapts the codebase to all relevant breaking changes. ### Config changes (all packages) - Rename `build.rollupOptions` → `build.rolldownOptions` in every `vite.config.ts` and `vitest.config.ts` - Remove the `_commonjsHelpers` chunk-name special-case — Rolldown handles CJS natively and this chunk no longer appears - Update `vite-plugin-static-copy` targets with `rename: { stripBase: true }` to match v4's new directory-structure-preserving behaviour - Replace `vite-tsconfig-paths` plugin with the native `resolve.tsconfigPaths: true` option (Vite 8 built-in) - Replace deprecated `customResolver` alias with a `resolveId` plugin hook for the `@metamask/kernel-shims/endoify` redirect - Update `js-trusted-prelude.ts` plugin to read `config.build.rolldownOptions?.input` ### `bundle-vat.ts` (kernel-utils) - Use `RolldownOutput` / `OutputChunk` types from `rolldown` instead of `Rollup.*` from `vite` - Replace `output.inlineDynamicImports: true` (Rollup-only) with `output.codeSplitting: false` - Add `removeDynamicImportsPlugin`: Rolldown rejects IIFE format whenever the bundle graph contains any `import()` expression, even with `codeSplitting: false`. Some third-party packages (viem, `@endo/*`) use lazy `await import(x)` for utilities that vats never call; the plugin replaces all string-literal dynamic imports with `Promise.resolve({})` to satisfy Rolldown's constraint - Add a module-level promise-queue mutex to serialize concurrent `bundleVat()` calls — Rolldown has global state that is corrupted when multiple IIFE builds run concurrently via `Promise.all` (as `kernel-cli` does when bundling a directory of vats) - Add `rolldown` as a peer dependency and update the `vite` peer dep range to `^8.0.6` ### `bundle-loader.ts` (ocap-kernel) - Add `exports: {}` to the SES Compartment endowments — Rolldown unconditionally emits `Object.defineProperty(exports, Symbol.toStringTag, ...)` in every IIFE bundle preamble, even for modules with no exports; without an `exports` endowment this throws inside the Compartment ### `stringify.test.ts` (kernel-utils) - Oxc serialises function declarations with tabs instead of spaces, so the whitespace-sensitive string comparison is replaced with `String(fn)` to stay bundler-agnostic ## Testing All 24 build tasks and all 45 test tasks pass (`yarn build` + `yarn test:dev:quiet` from the monorepo root, both cached and uncached). The key non-obvious behaviour changes are covered by the existing vat integration tests in `@ocap/kernel-test` (which build real vat bundles via `bundleVat` and execute them in SES Compartments) and by the `evm-wallet-experiment` build (which exercises the 4-vat `Promise.all` path through `kernel-cli`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because this upgrades the build/test toolchain (Vite/Vitest/Rolldown) and changes bundling semantics for vats and extension builds, which can cause subtle runtime or packaging regressions. > > **Overview** > Upgrades the monorepo to **Vite 8 / Vitest 4.1** (plus related tool bumps like Playwright, jsdom, and static-copy/checker plugins) and updates package configs accordingly. > > Migrates build/test configs from `build.rollupOptions` to `build.rolldownOptions`, adjusts static asset copy behavior (adds `rename.stripBase`), and replaces `vite-tsconfig-paths` with Vite’s native `resolve.tsconfigPaths` plus a custom `resolveId` hook for the `@metamask/kernel-shims/endoify` test redirect. > > Updates vat bundling to Rolldown by switching types/output options, adding a `removeDynamicImportsPlugin()` workaround for IIFE constraints, and serializing `bundleVat()` builds to avoid Rolldown concurrency issues; `loadBundle()` is hardened to support Rolldown-generated IIFE preambles (`exports`, `globalThis`, `global`). Minor follow-ups include exporting `register` from the OpenClaw plugin entrypoint and making `stringify` function tests bundler-output-agnostic. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3fc36bd. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f1d2bb3 commit 882fd94

44 files changed

Lines changed: 1239 additions & 1258 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
"@typescript-eslint/eslint-plugin": "^8.29.0",
7373
"@typescript-eslint/parser": "^8.29.0",
7474
"@typescript-eslint/utils": "^8.29.0",
75-
"@vitest/coverage-v8": "^4.0.16",
76-
"@vitest/eslint-plugin": "^1.6.5",
75+
"@vitest/coverage-v8": "^4.1.3",
76+
"@vitest/eslint-plugin": "^1.6.14",
7777
"@yarnpkg/types": "^4.0.1",
7878
"depcheck": "^1.4.7",
7979
"eslint": "^9.23.0",
@@ -90,7 +90,7 @@
9090
"lint-staged": "^15.5.0",
9191
"lodash": "^4.17.21",
9292
"patch-package": "^8.0.0",
93-
"playwright": "^1.58.2",
93+
"playwright": "^1.59.1",
9494
"prettier": "^3.5.3",
9595
"prettier-plugin-packagejson": "^2.5.10",
9696
"rimraf": "^6.0.1",
@@ -101,9 +101,8 @@
101101
"typedoc": "^0.28.1",
102102
"typescript": "~5.8.2",
103103
"typescript-eslint": "^8.29.0",
104-
"vite": "^7.3.0",
105-
"vite-tsconfig-paths": "^6.0.3",
106-
"vitest": "^4.0.16",
104+
"vite": "^8.0.6",
105+
"vitest": "^4.1.3",
107106
"vitest-fetch-mock": "^0.4.5"
108107
},
109108
"packageManager": "yarn@4.12.0",
@@ -130,7 +129,9 @@
130129
"@metamask/kernel-cli>@metamask/kernel-shims>@libp2p/webrtc>node-datachannel": false,
131130
"@metamask/kernel-cli>@metamask/kernel-utils": false,
132131
"vitest>jsdom>ws>bufferutil": false,
133-
"vitest>jsdom>ws>utf-8-validate": false
132+
"vitest>jsdom>ws>utf-8-validate": false,
133+
"@vitest/coverage-v8>@vitest/browser>ws>bufferutil": false,
134+
"@vitest/coverage-v8>@vitest/browser>ws>utf-8-validate": false
134135
}
135136
},
136137
"resolutions": {

packages/create-package/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"@typescript-eslint/eslint-plugin": "^8.29.0",
6161
"@typescript-eslint/parser": "^8.29.0",
6262
"@typescript-eslint/utils": "^8.29.0",
63-
"@vitest/eslint-plugin": "^1.6.5",
63+
"@vitest/eslint-plugin": "^1.6.14",
6464
"depcheck": "^1.4.7",
6565
"eslint": "^9.23.0",
6666
"eslint-config-prettier": "^10.1.1",
@@ -77,8 +77,8 @@
7777
"typedoc": "^0.28.1",
7878
"typescript": "~5.8.2",
7979
"typescript-eslint": "^8.29.0",
80-
"vite": "^7.3.0",
81-
"vitest": "^4.0.16",
80+
"vite": "^8.0.6",
81+
"vitest": "^4.1.3",
8282
"yargs": "^17.7.2"
8383
},
8484
"engines": {

packages/evm-wallet-experiment/openclaw-plugin/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,5 @@ const entry: PluginEntry = {
140140
register,
141141
};
142142

143+
export { register };
143144
export default entry;

packages/evm-wallet-experiment/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"@typescript-eslint/eslint-plugin": "^8.29.0",
100100
"@typescript-eslint/parser": "^8.29.0",
101101
"@typescript-eslint/utils": "^8.29.0",
102-
"@vitest/eslint-plugin": "^1.6.5",
102+
"@vitest/eslint-plugin": "^1.6.14",
103103
"depcheck": "^1.4.7",
104104
"eslint": "^9.23.0",
105105
"eslint-config-prettier": "^10.1.1",
@@ -116,8 +116,8 @@
116116
"typedoc": "^0.28.1",
117117
"typescript": "~5.8.2",
118118
"typescript-eslint": "^8.29.0",
119-
"vite": "^7.3.0",
120-
"vitest": "^4.0.16"
119+
"vite": "^8.0.6",
120+
"vitest": "^4.1.3"
121121
},
122122
"engines": {
123123
"node": ">=22"

packages/evm-wallet-experiment/test/integration/openclaw-plugin.integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { dirname, resolve } from 'node:path';
66
import { fileURLToPath } from 'node:url';
77
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
88

9-
import register from '../../openclaw-plugin/index.ts';
9+
import { register } from '../../openclaw-plugin/index.ts';
1010
import { makeWalletClusterConfig } from '../../src/cluster-config.ts';
1111

1212
type ToolResponse = {

packages/evm-wallet-experiment/test/openclaw-plugin.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { spawn } from 'node:child_process';
22
import { EventEmitter } from 'node:events';
33
import { beforeEach, describe, expect, it, vi } from 'vitest';
44

5-
import pluginEntry from '../openclaw-plugin/index.ts';
5+
import { register } from '../openclaw-plugin/index.ts';
66

77
vi.mock('node:child_process', () => ({ spawn: vi.fn() }));
88

@@ -107,7 +107,7 @@ function setupPlugin(): Map<string, ToolDefinition> {
107107
},
108108
};
109109

110-
pluginEntry.register(api);
110+
register(api);
111111
return tools;
112112
}
113113

packages/extension/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@metamask/eslint-config-typescript": "^15.0.0",
6464
"@ocap/kernel-test": "workspace:^",
6565
"@ocap/repo-tools": "workspace:^",
66-
"@playwright/test": "^1.58.2",
66+
"@playwright/test": "^1.59.1",
6767
"@testing-library/jest-dom": "^6.6.3",
6868
"@types/chrome": "^0.0.313",
6969
"@types/react": "^18.3.18",
@@ -72,7 +72,7 @@
7272
"@typescript-eslint/parser": "^8.29.0",
7373
"@typescript-eslint/utils": "^8.29.0",
7474
"@vitejs/plugin-react": "^5.1.2",
75-
"@vitest/eslint-plugin": "^1.6.5",
75+
"@vitest/eslint-plugin": "^1.6.14",
7676
"depcheck": "^1.4.7",
7777
"eslint": "^9.23.0",
7878
"eslint-config-prettier": "^10.1.1",
@@ -82,19 +82,19 @@
8282
"eslint-plugin-n": "^17.17.0",
8383
"eslint-plugin-prettier": "^5.2.6",
8484
"eslint-plugin-promise": "^7.2.1",
85-
"jsdom": "^27.4.0",
86-
"playwright": "^1.58.2",
85+
"jsdom": "^29.0.2",
86+
"playwright": "^1.59.1",
8787
"prettier": "^3.5.3",
8888
"rimraf": "^6.0.1",
8989
"tsx": "^4.20.6",
9090
"turbo": "^2.9.1",
9191
"typedoc": "^0.28.1",
9292
"typescript": "~5.8.2",
9393
"typescript-eslint": "^8.29.0",
94-
"vite": "^7.3.0",
95-
"vite-plugin-checker": "^0.9.1",
96-
"vite-plugin-static-copy": "^2.3.2",
97-
"vitest": "^4.0.16"
94+
"vite": "^8.0.6",
95+
"vite-plugin-checker": "^0.12.0",
96+
"vite-plugin-static-copy": "^4.0.1",
97+
"vitest": "^4.1.3"
9898
},
9999
"engines": {
100100
"node": ">=22"

packages/extension/vite.config.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default defineConfig(({ mode }) => {
6464
outDir,
6565
minify: !isDev,
6666
sourcemap: isDev ? 'inline' : false,
67-
rollupOptions: {
67+
rolldownOptions: {
6868
input: {
6969
background: path.resolve(sourceDir, 'background.ts'),
7070
offscreen: path.resolve(sourceDir, 'offscreen.html'),
@@ -79,13 +79,7 @@ export default defineConfig(({ mode }) => {
7979
},
8080
output: {
8181
entryFileNames: '[name].js',
82-
chunkFileNames: (chunkInfo) => {
83-
// Rename _commonjsHelpers to avoid underscore prefix extension issues
84-
if (chunkInfo.name === '_commonjsHelpers') {
85-
return 'commonjsHelpers.js';
86-
}
87-
return '[name].js';
88-
},
82+
chunkFileNames: '[name].js',
8983
assetFileNames: '[name].[ext]',
9084
},
9185
},
@@ -107,7 +101,9 @@ export default defineConfig(({ mode }) => {
107101
jsTrustedPrelude({ trustedPreludes }),
108102
viteStaticCopy({
109103
targets: staticCopyTargets.map((src) =>
110-
typeof src === 'string' ? { src, dest: './' } : src,
104+
typeof src === 'string'
105+
? { src, dest: './', rename: { stripBase: true } }
106+
: src,
111107
),
112108
watch: { reloadPageOnChange: true },
113109
silent: isDev,

packages/kernel-agents-repl/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@typescript-eslint/eslint-plugin": "^8.29.0",
6060
"@typescript-eslint/parser": "^8.29.0",
6161
"@typescript-eslint/utils": "^8.29.0",
62-
"@vitest/eslint-plugin": "^1.6.5",
62+
"@vitest/eslint-plugin": "^1.6.14",
6363
"depcheck": "^1.4.7",
6464
"eslint": "^9.23.0",
6565
"eslint-config-prettier": "^10.1.1",
@@ -75,8 +75,8 @@
7575
"typedoc": "^0.28.1",
7676
"typescript": "~5.8.2",
7777
"typescript-eslint": "^8.29.0",
78-
"vite": "^7.3.0",
79-
"vitest": "^4.0.16"
78+
"vite": "^8.0.6",
79+
"vitest": "^4.1.3"
8080
},
8181
"engines": {
8282
"node": ">=22"

packages/kernel-agents/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
"@typescript-eslint/eslint-plugin": "^8.29.0",
170170
"@typescript-eslint/parser": "^8.29.0",
171171
"@typescript-eslint/utils": "^8.29.0",
172-
"@vitest/eslint-plugin": "^1.6.5",
172+
"@vitest/eslint-plugin": "^1.6.14",
173173
"depcheck": "^1.4.7",
174174
"eslint": "^9.23.0",
175175
"eslint-config-prettier": "^10.1.1",
@@ -185,8 +185,8 @@
185185
"typedoc": "^0.28.1",
186186
"typescript": "~5.8.2",
187187
"typescript-eslint": "^8.29.0",
188-
"vite": "^7.3.0",
189-
"vitest": "^4.0.16"
188+
"vite": "^8.0.6",
189+
"vitest": "^4.1.3"
190190
},
191191
"engines": {
192192
"node": ">=22"

0 commit comments

Comments
 (0)