Skip to content

Performance regression since version above 6.0.2 #1349

Description

@DarkSorrow

Related plugins

Describe the bug

Hello,

I have a huge private project for a company where i use the plugin-react, i upgraded it to the 6.0.3 and 6.0.4 but both those version made the build go from 3 minutes to 2h54 minutes.
I had to downgrade to 6.0.2 for it to build again in two minutes. The project is relatively big with mui v9, icons react-flow and huggingface/trasnformers but i have to pin the plugin to its version 6.0.2 for it to work well

I can show you the vite config file which is very simple

import { defineConfig } from 'vite';
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
import babel from '@rolldown/plugin-babel';
import svgr from 'vite-plugin-svgr';

const host = process.env.NOVA_BACKEND_URL || 'http://localhost:8000';

/**
 * E2E + @cypress/code-coverage: instrument via [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul)
 * in the same Babel pass as the React compiler (matches production transforms).
 */
const e2eCoverage = process.env.CYPRESS_COVERAGE === 'true';

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    host: '0.0.0.0',
    open: false,
    port: 3000,
    watch: {
      usePolling: true,
      interval: 1000,
      ignoreInitial: true,
    },
    proxy: {
      '/api': {
        target: host,
        changeOrigin: true,
      },
      '/public': {
        target: host,
        changeOrigin: true,
      },
      '/oidc': {
        target: host,
        changeOrigin: true,
      },
    },
  },

  build: {
    outDir: 'build',
    target: 'es2020',
  },
  optimizeDeps: {
    include: [
      '@emotion/react',
      '@emotion/styled',
      '@mui/material',
      '@mui/material/InitColorSchemeScript',
      '@mui/icons-material',
      '@huggingface/transformers',
    ],
  },
  worker: {
    format: 'es',
  },
  plugins: [
    react(),
    babel({
      presets: [reactCompilerPreset({ target: '19' })],
      plugins: e2eCoverage
        ? [
          [
            'babel-plugin-istanbul',
            {
              cwd: process.cwd(),
              nycrcPath: '.nycrc.json',
            },
          ],
        ]
        : [],
    }),
    svgr({ svgrOptions: { icon: true } }),
  ],
});

And for additional info here are the tests i made before finding this

  • vite: 8.1.5 (also reproduced on 8.0.16 and 8.1.1 — not vite-version-dependent)
  • rolldown: 1.1.5 (also reproduced with rolldown pinned to 1.1.3/1.2.0 — not rolldown-version-dependent on its own)
  • @vitejs/plugin-react: 6.0.2 (works) vs 6.0.3/6.0.4 (hangs)
  • Build command: vite build (production), triggered via tsc && vite build

Edit

Well this is what the LLM said as well

Root cause identified: The hang is not from the @rolldown/pluginutils bump as your issue draft suggests — it's from a new defaultCodeFilter regex that plugin-react 6.0.3 introduced in reactCompilerPreset (the changelog omits this code change). The regex's third alternation [^\s:=(){}[],;]\s(?:(|[:=]\s*(?:function|()) catastrophically backtracks (O(n²)) on any module containing a multi-megabyte single-line sourceMappingURL base64 data URI — exactly what onnxruntime-web's unbundled .mjs files ship (4M-char lines in ort.all.mjs, 1.8M in ort.mjs, etc.), pulled into your graph by @huggingface/transformers. The old 6.0.2 regex (/\b[A-Z]|\buse/) has no quantifier and finishes in <1ms on the same input.

Reproduction

https://bolt.new/p/69393844

Steps to reproduce

No response

System Info

- OS: Windows 11
- Node: v24

- Linux (github action)

Used Package Manager

npm

Logs

No response

Validations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

p4-important ❗Violate documented behavior or significantly improves performance (priority)plugin: react

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions