Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@babel/plugin-proposal-class-properties #687

Open
thielpeter opened this issue Jan 20, 2021 · 2 comments
Open

@babel/plugin-proposal-class-properties #687

thielpeter opened this issue Jan 20, 2021 · 2 comments

Comments

@thielpeter
Copy link

thielpeter commented Jan 20, 2021

Hey there,

I get the following error:

./node_modules/@availity/reactstrap-validation-select/AvResourceSelect.js
SyntaxError: ...\node_modules\@availity\reactstrap-validation-select\AvResourceSelect.js: Support for the experimental syntax 'classProperties' isn't currently enabled (16:10):

  14 |   }
  15 | 
> 16 |   select = createRef();
     |          ^
  17 | 
  18 |   loadOptions = (...args) => {
  19 |     const [inputValue, , additional = {}] = args;

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-class-properties (https://git.io/vb4yQ) to the 'plugins' section to enable parsing.

I tried to resolve it with the following changes in package.json:

"babel": {
    "presets": [
      "@babel/preset-env",
      "@babel/preset-react"
    ],
    "plugins": [
      "@babel/plugin-proposal-class-properties",
      {
        "loose": true
      }
    ]
  },
  "devDependencies": {
    "@babel/core": "^7.12.10",
    "@babel/plugin-proposal-class-properties": "^7.12.1",
    "@babel/preset-env": "^7.12.11"
  }

But still the error is present. After spending some hours on this im a bit lost. Maybe someone can give me a hint on this. Thank you!

@jordan-a-young
Copy link
Member

Are you still experiencing this issue? This is how we handle it in our apps. Try that and see if it helps

@forest1206
Copy link

forest1206 commented Dec 3, 2021

for create-react-app project, you can use https://github.com/gsoft-inc/craco to override Create React App Configuration.

create craco.config.js

module.exports = {
  babel: {
    presets: ["@babel/preset-env", "@babel/preset-react"],
    plugins: [
      [
        "@babel/plugin-proposal-class-properties",
        {
          loose: true,
        },
      ],
    ],
  },
  devDependencies: {
    "@babel/core": "^7.12.10",
    "@babel/plugin-proposal-class-properties": "^7.12.1",
    "@babel/preset-env": "^7.12.11",
  },
};

update package.json

  "scripts": {
    "start": "craco start",
    "build": "craco build",
    "test": "craco test",
    "eject": "craco eject"
  },
  ... ...

it will work out now

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

No branches or pull requests

3 participants