esperantojs / esperanto

DEPRECATED: An easier way to convert ES6 modules to AMD and CommonJS
http://esperantojs.org
234 stars 21 forks source link

object literals, with named functions collide with imports #122

Closed stefanpenner closed 9 years ago

stefanpenner commented 9 years ago

input:

import { foo } from './foo';
var obj = {
  foo: function foo() {
    return true;
  }
};

foo();

output:

define(['./foo'], function (___foo) {
  'use strict';
​
  var obj = {
    foo: function ___foo.foo() {
      return true;
    }
  };
});
  ___foo.foo();

expected output:

define(['./foo'], function (___foo) {
​
  'use strict';
​
  var obj = {
    foo: function foo() {
      return true;
    }
  };
​
  ___foo.foo();
});

workaround:

import { foo as otherFoo } from './foo';
stefanpenner commented 9 years ago

also a problem with default imports

input:

import  foo from './foo';
var obj = {
  foo: function foo() {
    return true;
  }
};
foo();

output:

define(['./foo'], function (foo) {

  'use strict';

  var obj = {
    foo: function foo['default']() {
      return true;
    }
  };
  foo['default']();

});

expected output:

define(['./foo'], function (foo) {

  'use strict';

  var obj = {
    foo: function foo() {
      return true;
    }
  };
  foo['default']();

});

workaround:

import { default as otherFoo } from './foo';
Rich-Harris commented 9 years ago

Fixed in 0.6.19. Thanks for the test case @stefanpenner

stefanpenner commented 9 years ago

Oh man. Thanks dude!! Will include this with the next ember cli release