I’m writing an addon and I need to know at runtime which version of Ember the host app is using. I’ve got myself in a funny situation. I can think of a few ways to proceed, but I just wanted to do a quick gut-check here.
My addon’s test suite runs against multiple Ember versions with ember-try.
When running tests against 3.1 I need to use
import Ember from 'ember';
console.log(Ember.VERSION);
When running tests against 2.16 I need to use
import { VERSION } from `@ember/version`;
console.log(VERSION);
If I try to use the 3.1 way in 2.16 I get an ember eslint error. It wants me to use the new modules syntax.
If I try to use the 2.16 way in 3.1 I get a module not found error.
I’m working around this now, but I’m wondering how addon authors approach these sort of issues when working with multiple Ember versions? Also, is there an opportunity for me to provide a polyfill here?