-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
Using .babelrc for Babel 6 plugins will interfere w/ add-ons/dependencies that use Babel 5 #134
Comments
I need to update the docs for this (would love a PR to the README once you get it working). The basic gist is: // ember-cli-build.js
module.exports = function(defaults) {
let app = new EmberApp(defaults, {
babel: {
plugins: [
[require('babel-plugin-transform-object-rest-spread').default, /* any options needed for it */]
]
}
});
return app.toTree();
} |
FWIW, I do not believe we are allowing usage of |
Ya, as far as I know |
@rwjblue should it be this instead? // ember-cli-build.js
module.exports = function(defaults) {
let app = new EmberApp(defaults, {
'babel6': {
plugins: [
['transform-object-rest-spread', /* any options needed for it */]
]
}
});
return app.toTree();
}
|
@Turbo87 - |
Hm, found this issue, but cannot get this to work. With this #134 (comment) I get:
|
@simonihmig - Not sure if that is actually related to what this issue was about initially? Can you make a repro and report a separate issue? |
@rwjblue sorry for the confusion. In a clean fresh app, I do get the same exception with your proposed config, but I did get it to work when not requiring it directly as @Turbo87 suggested. So this config was working for me:
It did not work in the first place in an existing app, but that was due to some other upgrade issue (ember-cli-mocha)... So actually no issue to report, other than an example like this should maybe be mentioned in the docs as part of #127. |
Doesn't work for me in an addon's dummy app. I have this: module.exports = function (defaults) {
var app = new EmberAddon(defaults, {
babel : {
plugins : [
'transform-object-rest-spread',
],
}, This doesn't help. :( I still get "SyntaxError: Unexpected token" at an object spread. I also tried providing an incorrect plugin name -- and I don't see any error. Please help. |
@lolmaus depending on your Ember CLI version you might have to use |
@Turbo87 I'm on Ember CLI 2.13.2. I had tried |
Resolved with this in my addon's treeForAddon (tree) {
let addon = this.addons.find(addon => addon.name === 'ember-cli-babel') // find your babel addon
return addon.transpileTree(tree, {
babel : {
plugins : [
'transform-object-rest-spread',
],
},
})
}, |
Wait, this messes up addon modules names. 😭 Same as this. Come on, is it currently impossible to use rest/spread in Ember addons? |
@lolmaus - Not really sure what you expect to get with that tone. The functionality you desire is present and quite simple to use. |
The issue that was originally reported here has been addressed (a Closing... |
thanks @rwjblue, using babel6 worked! |
To answer what @lolmaus said (since I came here for the same reason) this is how I solved it: // index.js
init () {
this._super.init.apply(this, arguments);
if (!this.options.babel.plugins) {
this.options.babel.plugins = [];
}
this.options.babel.plugins.push('transform-object-rest-spread');
} |
@rwjblue I'm a bit frustrated by this same issue. fwiw it just doesn't seem to be simple to use (at least not from an addon) |
I'm trying to use a plugin (babel-plugin-transform-object-rest-spread) with the latest version of ember-cli-babel. Since it's not included as a preset in babel-preset-env, I'm forced to configure babel directly via .babelrc or package.json
According to Babel, it will search parent directories for a babelrc if it does not have one in its project dir. I am seeing this happening with some add-ons that are trying to use the plugin, which is a Babel 6 plugin, when the add-on is using babel v5.x.x, causing issues.
I was able to confirm by removing/replacing the .babelrc file
The text was updated successfully, but these errors were encountered: