react-universally icon indicating copy to clipboard operation
react-universally copied to clipboard

Babel error with ES6 arrow functions

Open nzeugaa opened this issue 9 years ago • 4 comments

Hi, I'm using the next branch and I'm having an issue with arrow functions. The following error is displayed near arrow functions when trying to build : BabelLoaderError: SyntaxError: Missing class properties transform.

I've added babel-preset-stage-0 in package.json and replaced stage-3 by stage-0 in .babelrc and internal/webpack/configFactory. Do I missing something ? Thanks so much for all your work.

nzeugaa avatar Apr 05 '17 22:04 nzeugaa

That should work fine although I wouldn't recommend going for stage-0 unless it's a very experimental project. You could just add the feature you wanted via the plugin:

yarn add babel-plugin-transform-class-properties -D --exact

Then add as plugin to the .babelrc and configFactory.

That should work.

ctrlplusb avatar Apr 06 '17 14:04 ctrlplusb

I hope you managed to resolve this.

ctrlplusb avatar Apr 06 '17 18:04 ctrlplusb

@ctrlplusb I fixed it by moving stage-0 after es2015. But I will go on the way you have suggested by adding plugins instead. Thanks a lot.

nzeugaa avatar Apr 06 '17 22:04 nzeugaa

In my case I solved this problem removing the "env" config for last two bowsers:

{ "presets": [ "react", "es2015", "stage-0", ["env", { "targets": { "browsers": ["last 2 versions"] } }] ] }

Just using: { "presets": [ "react", "es2015", "stage-0"] }

PabloMarch avatar Aug 07 '18 14:08 PabloMarch