Import an es6 module that may not exist

Just say that I am creating 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 if it does not exist in the client code. Basically I need a condition to check if the data of the ember data is available if they import it and do something, otherwise do not do this.

 if(ember data exists) { //do something } 
+6
source share
1 answer

I have the same question for general use of es6, but if you use ember-cli, you can look at the require._eak_seen object so that your code can look something like this:

 if(require._eak_seen['ember-data']){ //your code } 
+1
source

Source: https://habr.com/ru/post/980795/


All Articles