Skip to content
This repository was archived by the owner on Mar 29, 2018. It is now read-only.

For AMD modules, dependency var initialization should be on the first line #161

Closed
jarrodldavis opened this issue Sep 23, 2014 · 3 comments

Comments

@jarrodldavis
Copy link

Currently, I am using EmberScript with Ember CLI. When EmberScript compiles, it places some var declarations at the top. Once this transpiler gets a hold of that JavaScript, it places its declarations after the existing declarations, often causing this:

define("webapp/router", 
  ["ember","webapp/config/environment","exports"],
  function(__dependency1__, __dependency2__, __exports__) {
    "use strict";
    // Generated by EmberScript 0.0.14
    var Router;
    var set$ = Ember.set;
    var get$ = Ember.get;
    var Ember = __dependency1__["default"];var config = __dependency2__["default"];
    Router = Ember.Router.extend({ location: config.locationType });
    Router.map(function () {
      return this.route('items');
    });
    __exports__["default"] = Router;
  });//# sourceURL=webapp/router.js

As you can see, EmberScript expects Ember to already exist, but the transpiled code doesn't initialize that variable until after it is (attempted to be) accessed. Is there a way to have the transpiler move those var x = __dependency1__["default"] statements to the very top of the function? This could easily resolve issues people are having like ghempton/ember-script#44, ember-cli/ember-cli#1368, and aradabaugh/broccoli-ember-script#1.

@stefanpenner
Copy link

ember-cli is still using an old es6-module transpiler, so this repo may not be the best place check.

@ghempton input?

@eventualbuddha
Copy link
Contributor

Thanks for filing the issue. As @stefanpenner says, this is not an issue with the current version of the transpiler, so I won't be devoting any time to a fix. Perhaps you could try updating to use the newest version to see if there's some issue with it as well?

@jarrodldavis
Copy link
Author

My apologies, I didn't see joliss/broccoli-es6-concatenator#19.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants