Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Index.js needs to be updated to prevent 'app.import is not a function' #76

Closed
ASH-Bryan opened this issue Nov 22, 2017 · 2 comments
Closed
Labels

Comments

@ASH-Bryan
Copy link

You can read full details of this problem here (ember-cli/ember-cli#5747) but it basically shows up when ember-cli-swiper is installed into an addon that is then hosted in an app. There can be multiple levels of this. The above issues references a fix that I think will take care of this for swiper (https://github.com/jamesleebaker/ember-truncate/commit/42d58a1bbdc48f961c91b9fb92e12f5d9e835033):

var current = this;
// If the addon has the _findHost() method (in ember-cli >= 2.7.0), we'll just
// use that.
if (typeof this._findHost === 'function') {
  app = this._findHost();
}
// Otherwise, we'll use this implementation borrowed from the _findHost()
// method in ember-cli.
// Keep iterating upward until we don't have a grandparent.
// Has to do this grandparent check because at some point we hit the project.
do {
  app = current.app || app;
} while (current.parent.parent && (current = current.parent));
@Matt-Jensen
Copy link
Contributor

Sorry it's taken so long to get to this issue!

You're right that this addon doesn't support importing from an addon host, however I believe the correct ember-cli issue to reference is #3718 and the recommended fix is to replace app.import usage with Addon.import in order to prevent duplicate imports via isolated calls to app.import, mentioned in ember-cli PR: #5877.

As Addon.import is a newer feature, I think adding the import polyfill for older ember-cli versions would be ideal as well.

Any of that sound wrong @ASH-Bryan?

@ASH-Bryan
Copy link
Author

Sounds great, thanks!

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

No branches or pull requests

2 participants