DEV Community

Discussion on: CREATE LIBRARY OF REACT COMPONENT

Collapse
 
mmnoo profile image
Melissa Nunes

I get the same error as others with yarn build. It doesnt look like it knows about JSX. (I am new to React, so forgive me that I dont have a solution!)

yarn run v1.21.1
$ rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files --ignore __tests__,spec.js,test.js,__snapshots__
SyntaxError: src/lib/components/FormField/FormField.js: Unexpected token (15:9)
  13 |   value,
  14 | }) => {
> 15 |   return <div>fsdkhfsdkfjksdfjkls</div>
     |          ^
  16 | }

Even after installing @babel/cli @babel/core @babel/preset-react

Collapse
 
mmnoo profile image
Melissa Nunes

OK, it looks like for this error, my when I copy pasted the above config into .babelrc I didnt notice, nor did my IDE, that the double quotes were not kosher. Once I fixed the double quotes it complained :

Options {"absoluteRuntime":false} passed to <path>/node_modules/babel-preset-react-app/index.js which does not accept options.

So I removed those options and it seems to work without errors (at least so far...)