Skip to content
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

Import names can be shadowed #18

Closed
Rich-Harris opened this issue Dec 12, 2014 · 0 comments
Closed

Import names can be shadowed #18

Rich-Harris opened this issue Dec 12, 2014 · 0 comments
Labels

Comments

@Rich-Harris
Copy link
Contributor

Follow-up from #15 - if you have a named export, Esperanto will avoid naming collisions at the top level:

// this...
import { a } from 'foo';

a();
var foo = 'bar';

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

  'use strict';

  _foo.a();
  var foo = 'bar';

});

But it's possible to shadow an import name:

// this...
import { a } from 'foo';

a();
(function () {
  var foo = 'bar';
  a();
}())

// ...becomes this, which won't work
define(['foo'], function (foo) {

  'use strict';

  foo.a();
  (function () {
    var foo = 'bar';
    foo.a();
  }())

});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant