← All tasks
javascriptvitejs/vite #22826Not a task: not reproduced

vite:import-analysis fails on large files

envgap__vitejs__vite-22826

01 / FAILURE SIGNATURE

As reported upstream

[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.
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
efb98cce73f3f89c4f03936ab7741cd5b0636f5c
Manifest
packages/vite/package.json
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

vitejs/vite #22826 · read the original issue
## 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`:
```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`:
```ts
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/plugin-babel@0.2.x`, `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.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]