Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i split my Ember CLI addon into a vanilla Ember library and an Ember CLI addon wrapper?

I've created my first Ember CLI addon by following the instructions from the Ember CLI homepage. The addon works fine and it already has a couple of stars on Github: https://github.com/lolmaus/ember-cli-stained-by-children

The problem is that it's impossible to use the addon without Ember CLI, for example, on http://emberjs.jsbin.com/ .

I've seen other addons that don't have such a limitation: the library is implemented as a Bower package that can be used with or without Ember CLI, and also an Ember CLI addon wrapper is provided.

An example of such an addon is Simple Auth.

It has three repositories:

  • Main source code: ember-simple-auth.
  • Precompiled bower package: ember-simple-auth-component.
  • Ember CLI wrapper: ember-cli-simple-auth.

But it's hard to take example from those because Simple Auth is a huge library.

The questions are:

  1. How do i organize the main source code so that i can build different library types from it (global and Ember CLI-friendly AMD)?
  2. How do i organize the Ember CLI wrapper code? What should i do in it in order to leverage the library?
  3. How do i automate releases?
like image 988
Andrey Mikhaylov - lolmaus Avatar asked Nov 10 '22 20:11

Andrey Mikhaylov - lolmaus


1 Answers

There are multiple approaches to your problem so how your code should be organized is up to you. Right now, there's no simple build pipeline to generate a globals-based version, AMD version and addon in a single go. If you really want to achieve all of the above I'd say start by writing a (simple) globals-based version, then make a build script which wraps that in a AMD wrapper. Then wrap that AMD version in an addon.

like image 185
joostdevries Avatar answered Jan 04 '23 03:01

joostdevries