简体   繁体   中英

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:

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM