Skip to content

JSX in .js files breaks the optimizeDeps dependency scanner #5

Description

@hyf0

Problem

JSX in .js files breaks the Vite 8 / rolldown optimizeDeps dependency scanner.

react.dev keeps JSX in plain .js files (pages/404.js, pages/[[...markdownPath]].js, components/Layout/HomeContent.js, utils/prepareMDX.js, …) — Next/SWC handles this. vinext's main oxc transform handles it for SSR too, but the dep scanner has JSX disabled for .js:

(!) Failed to run dependency scan. Skipping dependency pre-bundling.
[PARSE_ERROR] Unexpected JSX expression
  Help: JSX syntax is disabled and should be enabled via the parser options

This is non-fatal at boot but cascades: with pre-bundling skipped, UMD/CJS deps (e.g. classnames) aren't interop'd and then crash under SSR (window is not defined).

Workaround used

optimizeDeps: { rolldownOptions: { moduleTypes: { '.js': 'jsx' } } }

Suggested fix

vinext should configure the optimizeDeps scanner to treat the app's .js as JSX (mirroring how it already treats .js for the main transform), so apps with JSX-in-.js pre-bundle correctly out of the box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions