1

I am trying to understand the differences between an Ember addon Vs normal package more from consuming side in my app.

So I would like to understand the following points;

  1. Differences in consuming both ? like what do we need to import, Brocfile changes, etc How are these available to individual modules say inside a route or controller, etc
  2. Is the installation process same for both ? Can both of them live in any repo or registry (like npm or bower registry)
  3. How or where do they reside in the build output i.e. in dist folder ?
  4. How do we decide whether to package something as addon Vs normal package (this is more from a developer perspective)?

You can also highlight any other significant differences.

copenndthagen
  • 49,230
  • 102
  • 290
  • 442

1 Answers1

0

Disclaimer: this is my understanding, but I have not built an addon myself, so I might have some misconceptions.

Ember addons are basically normal packages with some additional structure that makes them easier to integrate in an ember application.

  1. When using an Ember addon, you import things exactly like with any normal package. The only difference comes from objects that need to be registered with the resolver (services, adapers, helpers, etc): they will be automatically detected, added to your project and registered. This is why, after installing, say ember-notify, you can just Ember.inject.service('notify') in some component/controller and it will work.

    The details are for the addon author to choose. Usually, addons will register common objects that benefit from dependency injection (template helpers and services, mostly - though some addons define new injection types and come with some packaged, for instance ember-validations registers its validators). For other functionalities, you import things normally (import thing from 'addon/thing';).

  2. Ember addons are installed using npm (you find them in your project, under node_modules). You can even install them with npm yourself, just remember to add them to package.json so they are included by ember build.

  3. In the build output, they should simply be packaged, altogether, into assets/vendor.js.

  4. I would say the rule of thumb should be: if it is ember-specific, make it an addon. Otherwise, stick to normal package. But really, an ember addon is basically a normal package that has a specific layout.

Community
  • 1
  • 1
spectras
  • 13,105
  • 2
  • 31
  • 53
  • Thx...could you please clarify on the 1st point, like in which case do we have to explicitly import V/s automatic detection ? – copenndthagen Nov 24 '15 at 10:09
  • Edited. Basically, “it depends on addon author's choice so one has to read the addon's docs”. – spectras Nov 24 '15 at 10:24