2

I am creating a simple app using "react"

in package.json I import javascript package and react-component package from another project, if I use only javascript package it works, but if I include also react-component package I have an error.

I also created .babelrc file and babel.config.json

package.json

{
  "name": "my-proj",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.js",
  "private": true,
  "dependencies": {
    "moment": "2.29.1",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-router-dom": "^6.2.2",
    "react-scripts": "4.0.3",
    "web-vitals": "2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
  },
  "devDependencies": {
    "@mypackages/js-utils": "git+https://github.com/{ my-js-utils-package }.git",
    "@mypackages/react-components": "git+https://github.com/{ my-react-components-package }.git"
  }
}

.babelrc

{
   "presets": [
     ["@babel/preset-env", {"targets": {"node": "current"}}],
     ["@babel/preset-react", {"targets": {"node": "current"}}],
     "babel-preset-stage-0"
   ],
   "plugins": [
        "@babel/plugin-syntax-dynamic-import",
        "@babel/plugin-syntax-jsx",
        "@babel/plugin-proposal-class-properties"
   ]
}

babel.config.json

{
    "presets":[
        "@babel/preset-env",
        "@babel/preset-react"
    ],
  "comments": false,
  "plugins": [
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-syntax-jsx",
    "@babel/plugin-proposal-class-properties"
  ]
}

The error:

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

although I have set the babel files I still get this error

Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation. If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.

Vito Lipari
  • 795
  • 8
  • 35

0 Answers0