ember-modules.md

February 19, 2016 ยท View on GitHub

This approach to "pods" is really a more general modular approach that can exist alongside CS.

Instead of nesting modules within the top-level app dir, I'd propose that we eventually introduce a new top-level modules dir. This will work well for apps or engines or addons to either. For now though, modules could exist as app/modules alongside CS.

The modules approach is to use nested namespaces for everything and finish with a module name of the form ${name}-${type}.

This is the most straightforward representation:

modules
  posts
    new
      new-post-component.js
      new-post-template.hbs
    post-editor
      post-editor-button-component.js
      post-editor-button-template.hbs
      calculate-post-title-helper.js
    capitalize-helper.js
    new-route.js
    new-template.hbs
    post-editor-component.js
    post-editor-template.hbs
    post-viewer-component.js
    post-viewer-template.hbs
    titleize-helper.js
  app.js
  list-paginator-component.js
  list-paginator-template.hbs
  posts-adapter.js
  posts-model.js
  posts-serializer.js
  posts-route.js
  posts-template.hbs
  router.js

Modules can also be declared in the form ${name}/${type}, as follows:

modules
  posts
    new
      new-post
        component.js
        template.hbs
      route.js
      template.hbs
    post-editor
      post-editor-button
        component.js
        template.hbs
      calculate-post-title
        helper.js
      component.js
      template.hbs
    post-viewer
      component.js
      template.hbs
    capitalize
      helper.js
    titleize
      helper.js
    adapter.js
    model.js
    serializer.js
    route.js
    template.hbs
  list-paginator
    component.js
    template.hbs
  app.js
  router.js

These forms can easily be mixed. In general, we'll probably want to encourage creating a new directory for objects with the same name but differing types. Here is an interop representation:

modules
  posts
    new
      new-post
        component.js
        template.hbs
      route.js
      template.hbs
    post-editor
      post-editor-button
        component.js
        template.hbs
      calculate-post-title-helper.js
      component.js
      template.hbs
    post-viewer
      component.js
      template.hbs
    capitalize-helper.js
    titleize-helper.js
    adapter.js
    model.js
    serializer.js
    route.js
    template.hbs
  list-paginator
    component.js
    template.hbs
  app.js
  router.js