lundi 17 août 2020

Lazy import of external js file in ember.js

I am trying to import external js file in one of my application routes.

@(task(function* () {
  yield import('jquery/dist/jquery').then(module => module.default);
  yield import('jquery-ui/ui/widget.js').then(module => module.default);
  yield import('jquery-ui/ui/widgets/mouse.js').then(module => module.default);
  yield import('jquery-ui/ui/data.js').then(module => module.default);
  yield import('jquery-ui/ui/ie.js').then(module => module.default);
  yield import('jquery-ui/ui/scroll-parent.js').then(module => module.default);
  yield import('jquery-ui/ui/version.js').then(module => module.default);
  yield import('jquery-ui/ui/widgets/sortable.js').then(module => module.default);
  yield import('jquery-ui/ui/position.js').then(module => module.default);    
  yield import('pivottable/dist/pivot.js').then(module => module.default);
})) pivotTableRunner;

afterModel(){
  this.get('pivotTableRunner').perform();
}

Currently I’ve been importing that library in my pivotTableRunner, but it turned out, that I have had to make some modifications of that library imported from node_modules. I copied it’s content to another file, and placed it in vendor folder. Is there any way to import it lazily after pivotTableRunner task?




Aucun commentaire:

Enregistrer un commentaire