vitejs / vite-plugin-react-swc

Speed up your Vite dev server with SWC
MIT License
778 stars 50 forks source link

jsxDevRuntimeExports.jsxDEV is not a function #154

Closed samesfahani-tuplehealth closed 8 months ago

samesfahani-tuplehealth commented 9 months ago

I'm in the process of migrating our codebase from CRA to Vite and am getting close, but I am hitting an error now only when I vite build && vite preview for production. The dev server seemingly loads everything fine.

index-85d3be4e.js:292558 Uncaught TypeError: jsxDevRuntimeExports.jsxDEV is not a function
    at index-85d3be4e.js:292558:121

As I understand it, the jsx runtime should be automatic, and as I said, it works in dev, so what could be the difference when building for production?

ArnaudBarre commented 9 months ago

jsxDev should not be present in the build output, but I can't help you without a repro

samesfahani-tuplehealth commented 8 months ago

Your comment did somewhat help. I don't know why (still new to Vite so perhaps intended), but I need to specify NODE_ENV=production in the build script (even though the mode is production?). Either way, trivial issue (and not related to this plugin, probably).

ArnaudBarre commented 8 months ago

Yeah the mode in Vite is different from NODE_ENV, it something that you can customize to have staging mode or things like that. I think NODE_ENV is set to production in vite build, and it works without configuration on the default template so you may have something that override this somewhere in your build process and you just over-override, which is fine but if you find the root cause you can probably simplify things

samesfahani-tuplehealth commented 8 months ago

Had NODE_ENV=development in a shell rc file in case it helps anyone. Thanks for your help.