This repository was archived by the owner on Apr 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
This repository was archived by the owner on Apr 1, 2023. It is now read-only.
Issues with babel jsx transform #361
Copy link
Copy link
Open
Description
I am having issues with babel jsx transform following the steps in this article (it's a bit old but seems valid) https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html. I am trying to remove the need to import React into every component that uses JSX and can't seem to figure out how to get that working with this library. The relevant parts of my package.json and babel.config.js are as follows:
// package.json
{
"main": "dist/index.js",
"module": "dist/index.modern.js",
"source": "src/index.js",
"files": [
"dist"
],
"engines": {
"node": ">=10"
},
"scripts": {
"build": "microbundle-crl --no-compress --format modern,cjs",
"start": "microbundle-crl watch --no-compress --format modern,cjs",
"prepare": "run-s build",
"test": "run-s test:unit test:lint test:build",
"test:build": "run-s build",
"test:lint": "eslint .",
"test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"predeploy": "cd example && npm install && npm run build",
"deploy": "gh-pages -d example/build"
},
"peerDependencies": {
"react": "^16.0.0",
"react-html-parser": "^2.0.2",
"lodash": "^4.17.19",
"@material-ui/core": "^4.11.0",
"react-redux": "^7.1.1",
"redux": "^4.0.1",
"redux-localstorage": "^0.4.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"react-router-dom": "^5.1.1",
"react-dom": "^16.13.1",
"react-scripts": "^3.4.1",
"react-svg": "^12.0.0",
"reselect": "^4.0.0"
},
"devDependencies": {
"microbundle-crl": "^0.13.10",
"babel-eslint": "^10.0.3",
"cross-env": "^7.0.2",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.7.0",
"eslint-config-standard": "^14.1.0",
"eslint-config-standard-react": "^9.2.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-standard": "^4.0.1",
"gh-pages": "^2.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.4",
"babel-plugin-module-resolver": "^3.2.0"
},
"dependencies": {
"@babel/core": "^7.16.7",
"@babel/preset-env": "^7.16.7",
"@babel/preset-react": "^7.16.7",
"node-sass": "^7.0.0"
}
}
// babel.config.js
module.exports = {
presets: [
[
'@babel/preset-react',
{
runtime: 'automatic'
}
]
],
plugins: [
[
'module-resolver',
{
alias: {
src: './src',
actions: './src/actions',
components: './src/components',
constants: './src/constants',
contexts: './src/contexts',
hoc: './src/hoc',
selectors: './src/selectors',
styles: './src/styles',
themes: './src/themes',
utils: './src/utils'
},
extensions: ['.js', '.jsx', '.es', '.es6', '.mjs', '.scss']
}
]
]
}
Metadata
Metadata
Assignees
Labels
No labels