Skip to content

vinext dev SSR module-runner doesn't CJS-interop UMD/CJS deps (classnames window, parse-numeric-range exports) #6

Description

@hyf0

Problem

vinext dev is unusable for react.dev: the SSR module-runner inlines externalized deps without CJS interop, so common UMD/CJS deps throw at module eval.

Repro (npm run dev:vinext, then GET any page)

  • classnames (UMD, module.exports inside an IIFE) → ReferenceError: window is not defined at classnames/index.js.
  • parse-numeric-range (CJS) → ReferenceError: exports is not defined.
  • Result: every page 500s in dev.

vinext build + vinext start are fine — rolldown's full bundle interops these correctly. The problem is specific to the dev module-runner's on-demand inlining.

Workaround used (partial)

optimizeDeps.include / ssr.optimizeDeps.include for the offending deps — but this is whack-a-mole; any UMD/CJS dep with IIFE-wrapped module.exports hits it.

Suggested fix

The dev SSR module-runner should apply CJS→ESM interop to inlined node_modules deps (detecting module.exports/exports even inside an IIFE), matching the build path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1: highReal bug, cheap fix, do soonarea: devvinext dev experienceupstream: has-PRA cloudflare/vinext PR already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions