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

Resolving classes from an addon, within an engine, does not work #125

Closed
alexlafroscia opened this issue Nov 7, 2018 · 6 comments
Closed
Labels

Comments

@alexlafroscia
Copy link
Contributor

alexlafroscia commented Nov 7, 2018

I came across the need to resolve a class name from an addon today, and was delighted to see that, generally, this is supported!

function resolveExternalPath(importPath, options) {

However, I ran into an issue with Ember Engines that's blocking me from using this:

  • The class I want to compose from is in an addon
  • That addon is a dependency of an engine; the stylesheet that is trying to compose from the addon lives here
  • That engine is mounted into my application; the application does not have a direct dependency on the addon (nor should it)

Within that resolveExternal function linked to above, options.project is pointing to the application not the engine, so the addon can't be resolved.

The application does not have a direct dependency on that addon, and I don't want to introduce one, or we'll loose out on the benefits of lazy-loading that whole addon.

@alexlafroscia alexlafroscia changed the title Resolving classes from an addon, within an engine Resolving classes from an addon, within an engine, does not work Nov 7, 2018
@dfreeman
Copy link
Member

dfreeman commented Nov 7, 2018

Funnily enough, that bug has been in ember-css-modules forever, and we've been using addon resolutions that entire time and literally ran into this bug for the first time today.

You're exactly right: passing project there is a mistake; when we're operating on an addon it should be the parent addon rather than the root project.

@alexlafroscia
Copy link
Contributor Author

alexlafroscia commented Nov 7, 2018

Huh! How about that!

A tiny bit of extra context, that likely isn't necessary but I forgot to include previously: this was what gave away the issue when I was digging into it earlier

screen shot 2018-11-06 at 4 11 33 pm

the ownerName and the project are talking about different packages

@dfreeman
Copy link
Member

dfreeman commented Nov 7, 2018

Yep. You may already know this, but "owner" in this code (which predates Ember's use of the word, but now it's kind of confusing) roughly means "the app or addon that ember-css-modules is acting on behalf of", while in Ember CLI project always refers to the root thing, comprised of the host app and its whole tree of addons.

I have some time blocked off tomorrow to do some cleanup here and try and make sure our Broccoli output is stable; I'll aim to get a fix for this in as well.

@dfreeman dfreeman added the bug label Nov 7, 2018
@alexlafroscia
Copy link
Contributor Author

Sweet! I'm happy to work on the issue too (or with you) since we'd love to start composing classes from an addon this way in our engines.

@dfreeman
Copy link
Member

dfreeman commented Nov 8, 2018

Thanks for the offer! I ended up having @kehphin and @0xadada copilot on a bug squashing session this afternoon, and just published a fix in v1.0.3.

@alexlafroscia
Copy link
Contributor Author

Awesome!

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

No branches or pull requests

2 participants