Reputation: 2290
I'm using stage-0
Babel preset to be able to use expressions like myMethod = () => { /* code here */ }
like a class methods. Since I started to use this feature with stage-0
preset, my projects stopped working at iOS < 10
because of output code contains default function parameters function myFunc(a, b = 0) { /*code here*/ }
Is any ways here to configure Babel to transmit my code into lower standarts?
my webpack babel loader config:
presets: ["es2015", "stage-0", "react"]
P. S. Before I started to use stage-0
everything was OK, babel loader config was the same without the stage-0
.
Especially for Sulthan, code that generates an error
Component.prototype.has = function(key, opts, includeDefault = false) {
var i18n = this.props.i18n;
// Forth argument is the locale that should be used
// We can't use the active one because of the SSR and shared I18n state
// Also, we need to observe i18n.locale to detect changes, so this is useful
return I18n.has(key, opts, includeDefault, i18n.locale);
};
The error is:
SyntaxError:
Unexpected token '='.
Expected a ')' or a ',' after a parameter declaration. /bundle.js:950
I'll repeat, that this part of code generated by Babel as a result of transmitting a code of, obviously, i18n
library.
Upvotes: 2
Views: 318
Reputation: 2290
OK, guys, the problem was that one of my node_modules was harmony, and my Babel config excluded whole node_modules
catalogue.
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ["es2015", "stage-0", "react"],
plugins: ["transform-class-properties"]
}
I removed exclude: /node_modules/,
from config and now it works perfectly!
Upvotes: 0