You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Route and component/helper names clash with pods #18452
We use pods in our applications and are generally happy with it.
However, we noticed a pretty annoying issue, where a route name cannot match any helper or component name.
Now if I write this: <MyRoute />, it renders app/my-route/template.hbs.
Note that this also happens with helpers (e.g. we noticed when we created a route log, that it would render that route when using {{log 'something'}} instead of actually logging.
The only solution I found so far is to only use route names that do not match any component or helper name, but that's not really an ideal solution, of course.
That is only one variant of "pods". Technically, you can allow for any of the following to indicate a component:
# no special podModulePrefix
app/templates/components/foo.hbs
app/components/foo/template.hbs
app/foo/template.hbs
# with podModulePrefix of "pods"
app/pods/components/foo/template.hbs
app/pods/foo/template.hbs
app/templates/components/foo.hbs
Ah, OK, I was not aware that this app/foo/template.hbs was supposed to work, and even take precedence over app/components/foo/template.hbs. Is there a specific reason for that (especially for it taking precedence, as the latter example quite definitely seems more explicit to me) - I can't think of a scenario where I would have a file app/components/foo/template.hbs and would wantapp/foo/template.hbs to take precedence when invoking a component.
I also understand that this is then not that easy to change, but would be interesting to get some background information on this at least :)
I don't remember why wanted it to take precedence TBH, its been a very long time.
With Octane coming providing component/template colocation, I think we should completely deprecating usage of pods for components. As a step towards that, we could add a conditional that avoided the module lookup paths for pods components over in ember-resolver.
Going to close this though, as it isn't really a bug (though I do agree that it is frustrating/annoying). If you have the time / energy please file a bug over on ember-resolver for adding a guard to prevent pods lookup of components (with the eventual goal of deprecating when not set and we would have found a app/some-component/{component.js,template.hbs}).
Activity
rwjblue commentedon Oct 2, 2019
Unfortunately, this is a fundamental issue with the pods setup.
mydea commentedon Oct 2, 2019
But shouldn't components only be looked up in the components/ folder?
rwjblue commentedon Oct 2, 2019
That is only one variant of "pods". Technically, you can allow for any of the following to indicate a component:
rwjblue commentedon Oct 2, 2019
Here are some of the pods tests, if you'd like to dig more into what I was saying:
https://github.com/ember-cli/ember-resolver/blob/56e430493513ac5b0e270055d00bbd5332a96265/tests/unit/resolvers/classic/basic-test.js#L537-L694
mydea commentedon Oct 2, 2019
Ah, OK, I was not aware that this
app/foo/template.hbswas supposed to work, and even take precedence overapp/components/foo/template.hbs. Is there a specific reason for that (especially for it taking precedence, as the latter example quite definitely seems more explicit to me) - I can't think of a scenario where I would have a fileapp/components/foo/template.hbsand would wantapp/foo/template.hbsto take precedence when invoking a component.I also understand that this is then not that easy to change, but would be interesting to get some background information on this at least :)
rwjblue commentedon Oct 2, 2019
I don't remember why wanted it to take precedence TBH, its been a very long time.
With Octane coming providing component/template colocation, I think we should completely deprecating usage of pods for components. As a step towards that, we could add a conditional that avoided the module lookup paths for pods components over in ember-resolver.
Going to close this though, as it isn't really a bug (though I do agree that it is frustrating/annoying). If you have the time / energy please file a bug over on ember-resolver for adding a guard to prevent pods lookup of components (with the eventual goal of deprecating when not set and we would have found a
app/some-component/{component.js,template.hbs}).