unlayer / react-email-editor

Drag-n-Drop Email Editor Component for React.js
https://unlayer.com/
MIT License
4.59k stars 740 forks source link

Can't build with Vite #226

Open OddBlueDog opened 2 years ago

OddBlueDog commented 2 years ago

When I do npm run build I get an error. I'm using Vite currently instead of CRA.

The render function looks fine instead index.js of react-email-editor, so I'm unsure why I'm getting this error.

image

OddBlueDog commented 2 years ago

✓ 267 modules transformed.
[commonjs] Unexpected token (24:6) in C:/Users/Tom/Documents/Projects/Helpappy/frontend/node_modules/react-email-editor/src/index.js
file: C:/Users/Tom/Documents/Projects/Helpappy/frontend/node_modules/react-email-editor/src/index.js:24:6
22:
23:     return (
24:       <div
          ^
25:         style={{
26:           flex: 1,
error during build:
SyntaxError: Unexpected token (24:6) in C:/Users/Tom/Documents/Projects/Helpappy/frontend/node_modules/react-email-editor/src/index.js
    at Parser.pp$5.raise (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:19547:13)
    at Parser.pp.unexpected (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:16872:8)
    at Parser.pp$4.parseExprAtom (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:18922:10)
    at Parser.pp$4.parseExprSubscripts (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:18714:19)
    at Parser.pp$4.parseMaybeUnary (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:18680:17)
    at Parser.pp$4.parseExprOps (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:18613:19)
    at Parser.pp$4.parseMaybeConditional (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:18596:19)
    at Parser.pp$4.parseMaybeAssign (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:18564:19)
    at Parser.pp$4.parseParenAndDistinguishExpression (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:19018:28)
    at Parser.pp$4.parseExprAtom (C:\Users\Tom\Documents\Projects\Helpappy\frontend\node_modules\rollup\dist\shared\rollup.js:18881:41)```
ayushmanchhabra commented 2 years ago

Recently ran into this issue myself (my setup is CRA though). This means your bundler doesn't understand JSX syntax. My workaround was exposing the lib directory instead of downloading the relevant babel plugins.