Skip to content

Route and component/helper names clash with pods #18452

Closed

Description

@mydea

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.

I made a reproduction repo here:
https://github.com/mydea/ember-issue-reproductions/tree/component-route-clash

Summary:

// config/environment.js
 let ENV = {
    modulePrefix: 'ember-issue-reproductions',
    podModulePrefix: 'ember-issue-reproductions'
}

Files:

  • app/components/my-route/template.hbs
  • app/my-route/template.hbs

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.

This happens on 3.13 but also on older versions.

Activity

  1. rwjblue commented on Oct 2, 2019

    @rwjblue
    Member

    Unfortunately, this is a fundamental issue with the pods setup.

  2. mydea commented on Oct 2, 2019

    @mydea
    ContributorAuthor

    But shouldn't components only be looked up in the components/ folder?

  3. rwjblue commented on Oct 2, 2019

    @rwjblue
    Member

    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
    
  4. mydea commented on Oct 2, 2019

    @mydea
    ContributorAuthor

    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 want app/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 :)

  5. rwjblue commented on Oct 2, 2019

    @rwjblue
    Member

    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}).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions