Parcel as React Library bundler #7495
-
I've bee trying to use the setup suggested by the website for libraries (https://parceljs.org/getting-started/library/) but including react in the process to create a React library component. But keep getting errors. First
And after including
Not sure why is not able to parse jsx in watch mode. Here are the 2 files I have in place {
"name": "@poc/commons",
"version": "1.0.0",
"description": "",
"source": "src/index.js",
"module": "dist/module.js",
"scripts": {
"watch": "parcel watch",
"build": "parcel build"
},
"devDependencies": {
"parcel": "^2.0.1"
},
"dependencies": {
"@parcel/transformer-react-refresh-wrap": "^2.0.1"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
}
// src/index.js
export const Button = ({ children }) => <button>{children}</button>; NOTE: running |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
It was my fault. Parcel doesn't support "Arrow function expressions" by default. Including a {
"presets": ["react-app"]
} solves my issue. |
Beta Was this translation helpful? Give feedback.
-
FYI, I filed a bug on that issue, as we shouldn't have to use |
Beta Was this translation helpful? Give feedback.
It was my fault. Parcel doesn't support "Arrow function expressions" by default. Including a
.babelrc
withsolves my issue.