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
}
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With