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

[5.3.7] Issue with use in nested addon #9498

Closed
jrjohnson opened this issue Jun 21, 2024 · 4 comments · Fixed by #9500
Closed

[5.3.7] Issue with use in nested addon #9498

jrjohnson opened this issue Jun 21, 2024 · 4 comments · Fixed by #9500

Comments

@jrjohnson
Copy link
Contributor

Reproduction

This is reproducible in any app which consumes an addon that provides ember data, you can see it in our CI build failure when upgrading ember-data pin Ilios

However it's most easily seen in the test-app of a monorepo embroider v2 addon with:

ember addon test-addon -b @embroider/addon-blueprint --pnpm
cd test-addon
pnpm --filter=test-addon install ember-data webpack
pnpm start:test-app

Description

Installing ember-data after 5.3.4 in an add-on and consuming that add-on from an app causes a build failure with the error:
Cannot read properties of undefined (reading 'project') which comes from const dirname = app.project.root; in addon-main.cjs which was added in #9477.

I've seen this issue worked around before with something like the findApp method in ember-cli-babel because you need to traverse up the tree before you get to the actual app.

I've also used the slightly messy:

let current = this;
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));

Versions

ember-source 5.9.0
ember-cli 5.9.0
ember-data 5.3.7
@jrjohnson jrjohnson changed the title [5.3.4] Issue with use in nested add-on [5.3.7] Issue with use in nested addon Jun 21, 2024
@runspired
Copy link
Contributor

runspired commented Jun 21, 2024

I'm not sure this can be worked around but feel free to try. Unfortunately we don't have a real addon-main in v2 addons, its far more restricted (which is why we can't simply do findHost())

@jrjohnson
Copy link
Contributor Author

Thanks, this works if a copy it into a project so I have high hopes! I'll test as soon as it's released (should I back port it?) and can tweak it with a PR if needed. The complication with v2 adding is what prevented me from making any attempt at this myself, I'm just not familiar with the rules there yet.

@runspired
Copy link
Contributor

is already released!

@jrjohnson
Copy link
Contributor Author

Yeah it is! The process here has gotten super fast, LOVE IT!

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

Successfully merging a pull request may close this issue.

2 participants