### Describe the bug For SSR builds with `ssr.target: 'webworker'`, Vite still defaults `build.rolldownOptions.platform` to `'node'` for every server build. This causes Rolldown to emit `createRequire(import.meta.url)` for CJS interop, which crashes on Cloudflare Workers / `workerd` because `import.meta.url` is `undefined` in bundled worker modules. The worker fails during module initialization before any request is handled: ``` TypeError: The argument 'path' must be a file URL object, a file URL string, or an absolute path string. Received 'undefined' at createRequire (node:module:34:15) ``` Vite already treats `ssr.target === 'webworker'` as a special case elsewhere — `ssr.resolve.conditions` defaults to webworker/browser-style conditions, `resolveEnvironmentOptions()` threads `isSsrTargetWebworkerEnvironment` into resolve + `keepProcessEnv`, and `resolveRolldownOptions()` special-cases SSR webworker output defaults. But `resolveBuildEnvironmentOptions()` still hard-defaults all server builds to `platform: 'node'`. I am happy to take a stab at a PR if the team points us in the right direction. ### Reproduction https://github.com/jmalmo/vite-ssr-webworker-createrequire-repro ### Steps to reproduce 1. `git clone https://github.com/jmalmo/vite-ssr-webworker-createrequire-repro && cd vite-ssr-webworker-createrequire-repro` 2. `pnpm install` 3. `pnpm run build` 4. `pnpm run check` — shows `createRequire(import.meta.url)` in output 5. `pnpm run preview` — crashes with `TypeError: The argument 'path' must be a file URL object...` ### System Info ```shell System: OS: macOS 15.6.1 (Darwin 24.6.0) CPU: Apple M4 Max Memory: 48 GB Binaries: Node: 22.13.1 bun: 1.3.3 pnpm: 10.32.1 npmPackages: vite: npm:rolldown-vite@^7.3.1 => 7.3.1 rolldown: 1.0.0-rc.10 (transitive via rolldown-vite) ``` ### Used Package Manager bun ### Logs <details> <summary>Click to expand!</summary> ```shell # Build succeeds but output contains createRequire: $ bun run web:build && grep "createRequire" apps/web/.output/server/_chunks/jsx-runtime.mjs import { createRequire } from "node:module"; var __require = /* @__PURE__ */ createRequire(import.meta.url); # Worker crashes at startup: $ npx wrangler dev .output/server/index.mjs Uncaught TypeError: The argument 'path' must be a file URL object, a file URL string, or an absolute path string. Received 'undefined' at createRequire (node:module:34:15) at null.<anonymous> (jsx-runtime.mjs:34:33) ``` ### Validations - [x] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md) - [x] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md). - [x] Read the [docs](https://vite.dev/guide). - [x] Check that there isn't [already an issue](https://github.com/vitejs/vite/issues) that reports the same bug to avoid creating a duplicate. - [x] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to [vuejs/core](https://github.com/vuejs/core) instead. - [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite/discussions) or join our [Discord Chat Server](https://chat.vite.dev/). - [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.