-
Notifications
You must be signed in to change notification settings - Fork 15
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
ES6 support #21
Comments
Hi @eriknyk react-i18nliner does ES6 if you swap out the default esprima-fb for babel-acorn. You need to create an i18nliner plugin with the following: module.exports = function(i18nliner) {
// get new ast types into ast-types
require('babel-core/lib/babel/patch');
var acorn = require("babel-core/lib/acorn");
i18nliner.config.recastOptions = {
esprima: {
parse: function(src) {
var comments = [];
var tokens = [];
var ast = acorn.parse(src, {
plugins: { jsx: true },
ecmaVersion: 7,
locations: true,
onComment: comments,
onToken: tokens
});
ast.tokens = tokens;
ast.comments = comments;
return ast;
}
}
};
}; You'll also need ast-types and babel-core in your package.json. I'm using the plugin above in an app successfully, with ast-types v0.7.6 and babel-core v5.3.3... it should hopefully work with other versions, but I haven't verified. The plugin should be added to Since esprima-fb is now deprecated, I plan on making babel-acorn the default, so this workaround should not be needed for too much longer. We can leave this ticket open for now, and I'll close it once I push a new version with the switch. |
Thank you @jenseng I will try it! |
Question please Regards. |
Hi @jenseng https://github.com/eriknyk/react-i18nliner/tree/master/examples/webpack_es6 but I'm getting the following error:
I know that the babel setup is ok, because if I change the file webpack.config.js
I will appreciate a lot your help. Best Regards. |
i18nliner has (finally) moved to using babel/babylon, so the default behavior should be to support ES6/ES7 |
Hi,
Seems react-i18nliner is not supporting ES6 classes?
The text was updated successfully, but these errors were encountered: