What the agent does
The agent reads what the current build produces before it touches a config, because a Manifest V3 extension is only as portable as the paths in manifest.json. In an extension shaped like chibat/chrome-extension-typescript-starter, package.json runs webpack --config webpack/webpack.prod.js for build, the same with --watch for watch, npx jest for test and rimraf dist for clean, with webpack ^5.94.0, webpack-cli ^4.0.0, webpack-merge ^5.0.0, ts-loader ^8.0.0, copy-webpack-plugin ^14.0.0 and glob ^7.1.6 as dev dependencies and react ^18.2.0 as the only runtime one. webpack/webpack.common.js has four entries from src: popup.tsx, options.tsx, background.ts and content_script.tsx, writes them to dist/js/[name].js, splits shared code into a vendor chunk for every entry except background, and copies public/ to dist/. webpack.dev.js adds inline-source-map, webpack.prod.js sets production mode and nothing else.
public/manifest.json is the contract the new build has to meet: options_ui.page is options.html, action.default_popup is popup.html, the content script loads js/vendor.js then js/content_script.js on <all_urls>, and the service worker is js/background.js. public/popup.html and public/options.html each load js/vendor.js and then their own entry with plain script tags into a #root div that createRoot mounts. tsconfig.json targets es6 with module ES6, moduleResolution bundler, jsx react and rootDir src, and jest.config.js runs ts-jest over src with tsconfig.test.json, which only switches moduleResolution back to node. There is one test, src/__tests__/sum.ts, and .github/workflows/build.yml runs npm ci, npm run build and npm test on Node 20 and 22.
The split that matters is between extension pages and injected scripts. The popup and options pages can load ES modules, so the agent moves popup.html and options.html out of public/ to the project root, rewrites their script tags to point at src/popup.tsx and src/options.tsx, and lists both as build.rollupOptions.input in a new vite.config.ts with entryFileNames and chunkFileNames set to js/[name].js and a manualChunks rule that keeps React in js/vendor.js. A content script cannot be a module and a service worker should not depend on a shared chunk, so the agent gives those two entries a second config, vite.content.config.ts, that uses build.lib with formats: ['iife'], one self-contained file each, and emptyOutDir: false so it lands beside the first build. manifest.json and icon.png stay in public/, which Vite copies as-is, and the content script entry in the manifest drops js/vendor.js because the IIFE bundle carries what it needs.
build becomes vite build && vite build --config vite.content.config.ts, watch runs both with --watch, and clean keeps rimraf. The agent removes webpack, webpack-cli, webpack-merge, ts-loader, copy-webpack-plugin and glob, adds vite, deletes the webpack/ directory and updates the .vscode/tasks.json build task, which calls npm run watch by name and so keeps working. src/content_script.tsx only registers chrome.runtime.onMessage, so it needs no JSX plugin; jsx: react in tsconfig.json already means React.createElement, which esbuild handles for the two React entries. The agent runs npm run build, lists dist/ against every path in manifest.json, runs npm test, and launches Chromium in the sandbox with --load-extension=dist to confirm the service worker registers and the popup renders its URL and counter.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Migrate this Chrome extension's build from webpack to Vite and open a pull request. Read package.json, webpack/webpack.common.js, webpack/webpack.dev.js, webpack/webpack.prod.js, public/manifest.json, public/popup.html, public/options.html, tsconfig.json, tsconfig.test.json and jest.config.js first. Keep the output layout manifest.json expects: popup.html and options.html at the dist root, js/popup.js, js/options.js, js/vendor.js, js/background.js and js/content_script.js. Build the popup and options pages with vite build using rollupOptions.input and a vendor chunk for react and react-dom; build the content script and the service worker as self-contained IIFE bundles with a second Vite config using build.lib and emptyOutDir false, and remove js/vendor.js from the content_scripts entry in the manifest. Replace the build and watch scripts, remove webpack, webpack-cli, webpack-merge, ts-loader, copy-webpack-plugin and glob, add vite, and delete the webpack directory. Do not change src files other than imports that Vite requires, and keep Jest and the existing test as they are. Run npm run build, list dist against every path in manifest.json, run npm test, and load dist as an unpacked extension in Chromium to check the service worker starts and the popup renders. Paste the build and test output in the pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request that deletes webpack/ and adds vite.config.ts and vite.content.config.ts, moves popup.html and options.html out of public/ with their script tags pointing at src/, edits one line of public/manifest.json, and rewrites the scripts and devDependencies blocks of package.json with a regenerated package-lock.json. The description lists the files in dist/ after the build next to the paths the manifest names, and pastes the output of vite build for both configs and of npm test.
.github/workflows/build.yml runs npm ci, npm run build and npm test on the pull request, so the new build is checked on Node 20 and 22 before anyone loads it by hand. The agent's own check in the sandbox, loading dist/ into Chromium and opening the popup, is kept in the run's record with its screenshot.
A reviewer loads dist/ as an unpacked extension once, opens the popup and the options page, and confirms the content script still changes the page background on the button click. They check that the content script bundle has no import statements, that js/vendor.js is only referenced by the two HTML pages, and that package-lock.json no longer lists webpack. Then they merge.
Run it on every extension still on webpack
A team with several extensions, or one extension per browser store, sends one POST /o/{org}/sessions per repository with this prompt and that repository in resources. Each run reads its own manifest and entries, so an extension with a side panel or a second content script gets the extra inputs in its own config, and each run opens its own pull request.
Give the key a webhook_url and Rush POSTs run.completed when each turn ends, with session_url to read the pull request from; GET …/sessions/{id}/changes lists the files the agent changed with their diffs, which is a quick way to see whether a run touched anything under src/.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A bundler migration is mostly checking: does every path the manifest names still exist, does the content script still run as a classic script, does the popup still mount. In a Rush sandbox the agent builds, lists dist/, loads the extension into a real Chromium and clicks the popup, and every command and screenshot stays in the run's record beside the pull request, so the review starts from evidence rather than a description.
On a laptop this is an afternoon of trying configs against the manifest. The agent does it in one pass, runs the existing Jest suite and the CI workflow's commands before pushing, and the same request works unchanged on the next extension that is still on webpack.
Frequently asked questions
Why two Vite configs?
Because the popup and options pages can load ES modules and share a vendor chunk, while a Manifest V3 content script must be a single classic script with no imports. build.lib with the iife format produces that, and emptyOutDir: false lets the second build land beside the first.
Does it change manifest.json?
One line. The content script entry drops js/vendor.js because the IIFE bundle is self-contained; the popup, options and service worker paths stay exactly as they are, so the extension loads from dist/ the same way.
What happens to Jest?
Nothing. jest.config.js and tsconfig.test.json do not reference webpack, and src/__tests__/sum.ts keeps passing. The agent does not swap the test runner in the same pull request.
Can it keep the service worker as a module instead?
Yes, by adding "type": "module" to the background block of the manifest and building it with the first config. The prompt asks for an IIFE so the worker has no dependency on js/vendor.js, which the current webpack config also avoids with its splitChunks rule.
More Chrome Extension jobs
The same job on other stacks
- Migrate a Webpack 5 Project to Vite (webpack)