Skip to content

How should the micro-addon work at build time #30

@begedin

Description

@begedin

While writing the PR description for the ember-cli feature, I started to reconsider how micro-addons should work.

How it works now

Currently, the files are copied from a flat file structure in such a way that the following happens:

  • components are accessible via import MyComponent from 'app-name/components/my-component';
  • libraries are accessible via import MyLibrary from 'app-name/lib/my-library';
  • helpers are accessible via import MyHelper from 'app-name/helpers/my-helper';

There are 3 addon hooks we use to make this work:

  • treeForApp copies and renames component.js, helper.js, library.js
  • treeForAddon copies style.css (for components)
  • treeForTemplates copies template.hbs

I think this might not be 100% according to convention and where they're accessible from fells a bit illogical.

How I think it should work

  • treeForAddon should copy all of them into addon/[type]/addon-name.[extension]
  • treeForApp should create the standard import-export modules for components and helpers, so they are also directly accessible from the app. Libraries should be importable from the addon only, so they do not require import-export modules.
  • treeForApp might be able to create a template, but if that is impossible, then treeForTemplates should still be used for that

I think this would follow convention more closely.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions