Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

Support for the experimental syntax 'jsx' isn't currently enabled #363

Open
Ploppz opened this issue Jan 21, 2022 · 2 comments
Open

Support for the experimental syntax 'jsx' isn't currently enabled #363

Ploppz opened this issue Jan 21, 2022 · 2 comments

Comments

@Ploppz
Copy link

Ploppz commented Jan 21, 2022

I made a library with create-react-library called components.

What's weird is that it builds just fine (npm build) but when I try to use it in an application I get the error

ERROR in ../components/src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /home/ploppz/components/src/index.js: Support for the experimental syntax 'jsx' isn't currently enabled (18:10):

  16 |
  17 | function MyAppBar({ children, name }) {
> 18 |   return <AppBar title={<span>Title</span>} position={"sticky"}>
     |          ^
  19 |     <Toolbar>
  20 |       <a href="/">
  21 |         <img

In package.json: "components": "file:../components",

This application is a CRA application that worked fine before I tried to include this library - it definitely has JSX enabled.
When I google my problem, the solutions I find have to change the babel config, but afaik, I cannot do that without ejecting the CRA...

Please tell me if you need more information.

@meneerrook
Copy link

Did you end up finding a solution? i'm having the exact some problem except with my own component library. I just want to be able to install my own package without having to 'pre-build' it.

@Ploppz
Copy link
Author

Ploppz commented Apr 8, 2022

@meneerrook My solution was to not use create-react-library.
I got help in the React JS room on Matrix by a very helpful individual who shared a draft of a guide that she had written, on how to set up a react library (no fancy tools).
Link to first message: https://matrix.to/#/!duqxVZLLoRUIktuuYH:matrix.org/$XJPJLYdzk3tE89I1dJKcm5-NKY2LCNv7HRLafpUIJcM?via=matrix.org&via=t2bot.io&via=chat.tgp.io (subsequent messages will be helpful to fill in some missing information)

It turns out that despite it actually being rather straightforward, there's no good guide to do it except for this one which sadly has not yet been finalized and released. That's at least the only resource that helped for me (I tried to go through several guides, all of them more complex, and always ended up getting some error).

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

No branches or pull requests

2 participants