Skip to content

Commit

Permalink
fix: attempt traversal to find project (#9500)
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired authored Jun 21, 2024
1 parent 583668e commit 4ad5c74
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/-ember-data/addon-main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ if (pkg['ember-addon'].version === 1) {
delete addon.treeForApp;
}

function findApp(addon) {
let current = addon;
let app;

// 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));

return app;
}

const included = addon.included;
addon.included = function includedIntercept() {
// we access this as a side-effect to ember-cli will give us a super call
Expand All @@ -16,7 +29,7 @@ addon.included = function includedIntercept() {
return included?.apply(this, arguments);
}
this.hasBeenCalled = true;
const app = this.app;
const app = findApp(this);
const dirname = app.project.root;
const { setConfig } = require('@warp-drive/build-config/cjs-set-config.cjs');
setConfig(app, dirname, Object.assign({}, app.options?.emberData, { ___legacy_support: true }));
Expand Down

0 comments on commit 4ad5c74

Please sign in to comment.