8

Just say I create an addon that is shared with other users and I need to import ember-data.

import DS from 'ember-data';

How can I import this given it might not exist in the client code. Basically I need a condition to check if ember-data is available, if so import it and do something, else don't do it.

if(ember data exists) {
  //do something
}
jax
  • 37,735
  • 57
  • 182
  • 278

1 Answers1

1

I have the same question for general es6 usage, but assuming you're using ember-cli you can look at the require._eak_seen object so your code could potentially look something like:

if(require._eak_seen['ember-data']){
  //your code
}
JackCA
  • 4,885
  • 4
  • 27
  • 26