Skip to content

Commit 4ad5c74

Browse files
authored
fix: attempt traversal to find project (emberjs#9500)
1 parent 583668e commit 4ad5c74

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/-ember-data/addon-main.cjs

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ if (pkg['ember-addon'].version === 1) {
88
delete addon.treeForApp;
99
}
1010

11+
function findApp(addon) {
12+
let current = addon;
13+
let app;
14+
15+
// Keep iterating upward until we don't have a grandparent.
16+
// Has to do this grandparent check because at some point we hit the project.
17+
do {
18+
app = current.app || app;
19+
} while (current.parent.parent && (current = current.parent));
20+
21+
return app;
22+
}
23+
1124
const included = addon.included;
1225
addon.included = function includedIntercept() {
1326
// we access this as a side-effect to ember-cli will give us a super call
@@ -16,7 +29,7 @@ addon.included = function includedIntercept() {
1629
return included?.apply(this, arguments);
1730
}
1831
this.hasBeenCalled = true;
19-
const app = this.app;
32+
const app = findApp(this);
2033
const dirname = app.project.root;
2134
const { setConfig } = require('@warp-drive/build-config/cjs-set-config.cjs');
2235
setConfig(app, dirname, Object.assign({}, app.options?.emberData, { ___legacy_support: true }));

0 commit comments

Comments
 (0)