Skip to content

Commit 7fd2b39

Browse files
authored
Merge pull request #99 from nathanhammond/find-host
Support hoisting to nearest host.
2 parents 9590c31 + cea3908 commit 7fd2b39

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

lib/index.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
// Support old versions of Ember CLI.
2+
function findHost() {
3+
var current = this;
4+
var app;
5+
6+
// Keep iterating upward until we don't have a grandparent.
7+
// Has to do this grandparent check because at some point we hit the project.
8+
// Stop at lazy engine boundaries.
9+
do {
10+
if (current.lazyLoading === true) { return current; }
11+
app = current.app || app;
12+
} while (current.parent && current.parent.parent && (current = current.parent));
13+
14+
return app;
15+
}
16+
117
module.exports = {
218
name: 'ember-browserify',
319

@@ -12,11 +28,7 @@ module.exports = {
1228
newImportApi = true;
1329
}
1430

15-
// Stop-gap measure to support another addon
16-
// consuming this addon. https://github.com/ef4/ember-browserify/issues/29
17-
if (typeof app.import !== 'function' && app.app) {
18-
app = app.app;
19-
}
31+
app = findHost.call(this);
2032

2133
var enableSourcemaps = app.options.sourcemaps && app.options.sourcemaps.enabled && app.options.sourcemaps.extensions.indexOf('js') > -1;
2234

0 commit comments

Comments
 (0)