Skip to content

vite:import-analysis fails on large files #22826

Description

@lukasbash

Describe the bug

Starting in Vite 8.1.1, the dev server crashes with a parse error on a pre-bundled dependency when @vitejs/plugin-react is used alongside @rolldown/plugin-babel with reactCompilerPreset. Vite 8.1.0 works correctly.

Error

[vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
  Plugin: vite:import-analysis
  File: /.../node_modules/.vite/deps/@tabler_icons-react.js

The error fires repeatedly (×60) on startup, suggesting the pre-bundled output for @tabler/icons-react contains syntax the import-analysis step cannot parse.

Reproduction

vite.config.ts:

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

export default defineConfig({
  plugins: [
    react(),
    babel({ presets: [reactCompilerPreset()] }),
  ],
});

Any file importing from @tabler/icons-react:

import { IconHome } from "@tabler/icons-react";

Steps to reproduce

  1. Set up a Vite project with the config above
  2. Install @tabler/icons-react, @vitejs/plugin-react@6, @rolldown/[email protected], babel-plugin-react-compiler
  3. Run vite dev
  4. Dev server fails immediately with the error above

Expected behavior

Dev server starts normally (as it does with Vite 8.1.0).

Actual behavior

vite:import-analysis fails to parse the pre-bundled @tabler_icons-react.js output.

Environment

Vite 8.1.1 (works on 8.1.0)
@vitejs/plugin-react 6.0.3
@rolldown/plugin-babel 0.2.3
babel-plugin-react-compiler 1.0.0
@tabler/icons-react 3.44.0
Node 24.x
OS macOS arm64

Workaround

Pin vite to 8.1.0.

Notes

@rolldown/plugin-babel excludes node_modules by default via DEFAULT_EXCLUDE = [/[/\\]node_modules[/\\]/], but reactCompilerPreset uses a code-based filter (/forwardRef|memo|…/) rather than a path filter. @tabler/icons-react uses forwardRef extensively and matches this filter. Suspect something changed in 8.1.1 in how the optimizer environment is configured such that the preset's applyToEnvironmentHook (env.config.consumer === "client") now matches during dep pre-bundling, where it did not in 8.1.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    p4-importantViolate documented behavior or significantly improves performance (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions