Skip to content

Duplicate React instance when adding Deno plugin + cjs-to-esm and importing UI component #894

@nestarz

Description

@nestarz

Related plugins

Describe the bug

I started from the base example and added two plugins: a Deno plugin and the official cjs-to-esm plugin. I also import a component from the base UI lib. After these changes the app ends up with a duplicate instance of React (two React copies), which breaks hooks and causes errors like “Invalid hook call”.

What I changed

• Based this on the base example

• Added a Deno resolution plugin (same as the one discussed in vitejs/vite#20849 )

• Added cjstoesm (cjs-to-esm) plugin

• Imported a component from the base UI lib

Expected behavior: Single React instance used across the app and plugins; no hook errors.

Actual behavior: Duplicate React instance (two copies), causing hook errors and runtime issues.

Reproduction

https://github.com/nestarz/deno-vite-issue-3

Steps to reproduce

  1. Clone https://github.com/nestarz/deno-vite-issue-3

  2. Install deps / follow repo’s README to run dev build

  3. Start dev server (or build)

  4. Load the app and observe console errors about duplicate React/Invalid hook call

System Info

macos 26, deno 2.5.3

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions