Skip to content

bundledDev: @vitejs/plugin-react-swc throws an error in dev #1271

Description

@dorshinar

Related plugins

Describe the bug

Hi!
I'm trying to enabled bundledDev with @vitejs/plugin-react-swc but it doesn't seem to support it.

The error:

✘ Build error: Build failed with 1 error:

[plugin vite:build-html]
TypeError: Cannot read properties of undefined (reading 'config')
    at PluginContextImpl.transformIndexHtml (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/@vitejs/plugin-react-swc/index.js:137:46)
    at applyHtmlTransforms (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/vite/dist/node/chunks/node.js:23937:26)
    at PluginContextImpl.generateBundle (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/vite/dist/node/chunks/node.js:23725:20)
    at PluginContextImpl.handler (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/vite/dist/node/chunks/node.js:32835:13)
    at plugin (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/rolldown/dist/shared/bindingify-input-options-CzVhGygm.mjs:1709:18)
    at plugin.<computed> (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/rolldown/dist/shared/bindingify-input-options-CzVhGygm.mjs:1961:18)

I created a minimal reproduction

Reproduction

https://github.com/dorshinar/vite-bundled-dev-react-swc-repro

Steps to reproduce

npm install
npm run dev

System Info

System:
    OS: macOS 26.5.1
    CPU: (16) arm64 Apple M4 Max
    Memory: 7.89 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.15.0 - /Users/<redacted>/.local/state/fnm_multishells/83652_1782737041918/bin/node
    npm: 11.12.1 - /Users/<redacted>/.local/state/fnm_multishells/83652_1782737041918/bin/npm
    pnpm: 11.6.0 - /opt/homebrew/bin/pnpm
    bun: 1.2.21 - /Users/<redacted>/.bun/bin/bun
    Deno: 2.8.3 - /opt/homebrew/bin/deno
  Browsers:
    Chrome: 149.0.7827.201
    Edge: 149.0.4022.98
    Safari: 26.5
  npmPackages:
    @vitejs/plugin-react-swc: ^4.3.1 => 4.3.1 
    vite: ^8.1.0 => 8.1.0

Used Package Manager

pnpm

Logs

✘ Build error: Build failed with 1 error:

[plugin vite:build-html]
TypeError: Cannot read properties of undefined (reading 'config')
at PluginContextImpl.transformIndexHtml (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/@vitejs/plugin-react-swc/index.js:137:46)
at applyHtmlTransforms (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/vite/dist/node/chunks/node.js:23937:26)
at PluginContextImpl.generateBundle (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/vite/dist/node/chunks/node.js:23725:20)
at PluginContextImpl.handler (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/vite/dist/node/chunks/node.js:32835:13)
at plugin (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/rolldown/dist/shared/bindingify-input-options-CzVhGygm.mjs:1709:18)
at plugin. (file:///private/var/folders/jw/3x58yzwd6nbdk58lnk29jx8c0000gp/T/opencode/vite-bundleddev-repro/node_modules/rolldown/dist/shared/bindingify-input-options-CzVhGygm.mjs:1961:18)

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions