ESBUILD Error building site: JSBUILD: failed to transform "index.jsx" (text/jsx): Unexpected "<"

Hi, I’m using the newish @bep esbuild Hugo pipeline https://gohugo.io/hugo-pipes/js/ as mentioned here: React Hugo Starter i.e. it requires Hugo >= 0.74.2 !!

Now I’m trying to get a more complex React project running within Hugo here: https://github.com/dayhaysoos/use-shopping-cart/tree/master/examples/cra

And I’m hitting this error: Error building site: JSBUILD: failed to transform “index.jsx” (text/jsx): Unexpected “<” despite there is not JSX angled brackets in https://github.com/kaihendry/react-hugo-esbuild/blob/uSC-cra/assets/index.jsx

Sorry, the React / build chain is something I am a bit uncertain about. So any debug info or pointers would be great. I think it might be an esbuild issue and I need Babel. Btw I don’t know if https://gohugo.io/hugo-pipes/babel/ is supposed to be married with https://gohugo.io/hugo-pipes/js/ somehow??

Nonetheless I did try creating another project https://github.com/kaihendry/react-hugo-babel but that has its own problems. It moans about require is not defined and I have no idea how to fix it. cc @jmooring Many thanks!

A guy https://www.christopherbiscardi.com/ told me that I need to rename my JSX in .js files to .jsx for esbuild. Now I am much further!

Now I am hitting Uncaught ReferenceError: process is not defined despite the env being set here IIUC

Hugo Static Site Generator v0.74.3/extended linux/amd64 BuildDate: unknown

Ah! Uncaught ReferenceError: process is not defined was actually just moaning that a process.env.FOOBAR was not defined!! 🤦

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.