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

legacy-register initializer is incorrectly added to Ember 2.0.1 addon #100

Closed
indirect opened this issue Sep 18, 2015 · 6 comments
Closed

Comments

@indirect
Copy link

I'm trying to use ember-moment as dependency of the ember-cp-validations addon. For some reason, the legacy-register initializer is getting included in the built application, even though the app is using Ember 2.0.1. I've created an extremely minimal ember addon where you can see the error in action—it's basically just an empty ember addon plus ember-moment. To see the problem, do this:

git clone https://github.com/indirect/ember-moment-initializer-demo
cd ember-moment-initializer-demo
bower install
npm install
ember serve

Then open http://localhost:4200 in your browser, and check the console to see the initializer throwing an exception by trying to use an API that has been removed in Ember 2.

I spent a bunch of time trying to debug this, and as far as I can tell, the ember-moment index.js file is correctly able to tell that the app is using Ember 2, and the treeForApp does not actually include the initializer. In spite of that, however, the tree for the final dummy application for this addon does somehow include it. My extremely hacky solution to this problem was to add this to my ember-cli-build.js:

  app.appAndDependencies = function() {
    var tree = EmberApp.prototype.appAndDependencies.apply(this, arguments);
    return stew.rm(tree, 'broken-moment-demo/initializers/legacy-register.js');
  };

Any help figuring out how this initializer is ending up in the build tree, and how to stop that from happening, would be great. :)

@indirect
Copy link
Author

I should point out that, for the record, I am seeing this problem both in an ember-cli application running Ember 2.0.1 and an ember-cli addon running Ember 2.0.1. It was easier to create the minimal reproduction case based on the addon, so I did that.

If there's anything else I can do that would be helpful (or if there are any pointers that would help in debugging this), please let me know. I've already spent a lot of time digging around inside the broccoli trees, and I don't mind spending more if it will help get the problem solved.

Thanks!

@stefanpenner
Copy link
Collaborator

It appears included isn't being invoked twice but the addon tree is invoked twice. (which itself is dubious).

Taking a look..

@stefanpenner
Copy link
Collaborator

A quick fix would be for this check to be inverted, rather make the legacy the opt in, rather then opt out.

The root issue appears to be multiple paths to initializing addons due to how the legacy registry worked...

@jasonmit
Copy link
Collaborator

I am fine at this point dropping legacy support and versioning accordingly. Thoughts Stefan?

@stefanpenner
Copy link
Collaborator

I am fine at this point dropping legacy support and versioning accordingly. Thoughts Stefan?

👍

@jasonmit
Copy link
Collaborator

Versioned as 4.0.0 and also will resolve this issue.

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

No branches or pull requests

3 participants