Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: React is not defined when using JS in Vite #7885

Closed
1 task done
brookslybrand opened this issue Nov 2, 2023 · 2 comments
Closed
1 task done

ReferenceError: React is not defined when using JS in Vite #7885

brookslybrand opened this issue Nov 2, 2023 · 2 comments

Comments

@brookslybrand
Copy link
Contributor

What version of Remix are you using?

2.2.0

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

Start a new vite-based remix app

npx create-remix@nightly --template remix-run/remix/templates/unstable-vite

Add a route with a .jsx extension and navigate to it

See your browser blow up

Expected Behavior

Router renders

Actual Behavior

Route does not render unless you manually install @vittejs/plugin-react and update the config to be

import { unstable_vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
  plugins: [remix(), react()],
});

I'm pretty confident we don't want to users to manually have to import the react plugin. At a minimum, js/jsx should definitely work out of the box

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Nov 3, 2023

I'm attempting to fix this issue in #7888
I think the workaround could work directly from local vite config by:

import { unstable_vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  plugins: [remix(), tsconfigPaths()],
  //
  // WORKAROUND
  //
  esbuild: {
    jsx: "automatic"
  }
});

@markdalgleish
Copy link
Member

Fixed by #7888.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants