ember-cli-babel
ember-cli-babel copied to clipboard
Error transpiling some Ember functions
Hi, I'm trying to use the new import syntax (@ember/package) but I think I found an issue when using some Ember functions (like Ember.warn).
For example, this piece of code...
import { warn } from '@ember/debug';
const a = () => warn('a');
const b = () => { warn('b') };
const c = () => { return warn('c') };
const d = function(){ warn('d') };
const e = function(){ return warn('e') };
Produces this after building the application:
var a = function a() {
return warn('a');
};
var b = function b() {
(true && Ember.warn('b'));
};
var c = function c() {
return warn('c');
};
var d = function d() {
(true && Ember.warn('d'));
};
var e = function e() {
return warn('e');
};
In the example, the functions b and d are correct but the a, c and e are not ok because it will throw a ReferenceError.
For some reason, only the functions that returns something have the wrong code.
Don't know if this is the correct repo to publish this issue but I think it could be related with babel transformations.
I've tested it in my companies application, and an empty projects using v2.16.2 and v2.18.0.
Thank you for the awesome bug report! I believe from your description that you are struggling with the issue reported in https://github.com/chadhietala/babel-plugin-debug-macros/issues/46. Would definitely love help fixing that one if you have time...
Yes, that's the issue. Then you can close this one, I wasn't sure the repo where the problem is located. I'll try to find the problem and if I find something I'll post it. Thanks!
related: https://github.com/emberjs/ember.js/issues/16139