Can an addon blacklist itself?

Ember CLI has an API that lets host apps blacklist addons. I’m wondering if Addons have the ability to do this themselves, in certain environments?

The motivation for this is say I’m writing an addon used for testing purposes. I want my addon to run in dev and test, but I never want it to affect the production build. I could be diligent about all the code I write in index.js hooks and ensure nothing happens, but the “safest” way seems to be to blacklist it in the production environment altogether.

The host app can do this but it would be nice if the addon itself could be responsible for excluding itself in prod. Is it possible?


There is an addon.isEnabled hook (TIL). I personally haven’t tried it, but stepping through the ember-cli source it might be useful for this.


Ya, generally isEnabled hook is the right thing for this.