Fixing Dojo's and JQuery dependant libraries multipleDefine conflict via Javascript

2106
3
07-06-2018 01:23 PM
SamuelAbati
New Contributor III

This question has been answered many times before, and I know one solution is to simply change it so (Esri's)dojo is the last one to load.

Problem is I'm working on a modular widget that has no access to the page's html to change the order, I must only load libraries via Dojo's AMD Loader.

Folder structure :

/Widget

   --/Widget.js

   --/Datatable.js

This is the Widget.js file:

define([
   './Datatable',
   'https://code.jquery.com/jquery-3.3.1.min.js',
   'https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.js',
], function(Datatable){ ... }

And Datatable.js (just another module I created for organization) :

define([
   'https://cdn.datatables.net/v/bs4/dt-1.10.18/r-2.2.2/datatables.min.js'
],function(){ ... }‍‍‍‍

I have two major issues here;

1) The AMD Loader is asynchronous and doesn't resolve non-AMD modules dependencies, meaning that order should be important for these libraries.

datatables.min.js requires bootstrap.bundle.js that requires jquery-3.3.1.min.js

So, If I'm lucky the request will load in order depending on latency, not reliable at all.

2) Both Bootstrap and Datatable generic javascript files raise a "multipleDefine" error, probably due to them trying to define "jquery", I'm really not sure how to fix this.

How can I resolve these 2 problems?

0 Kudos
3 Replies
SamuelAbati
New Contributor III

Any help with this? Robert Scheitlin, GISP

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Samuel,

  Sorry I do not know the answer. I do not use other third party libraries like jQuery with WAB. I find no need for them.

0 Kudos
diaconori
New Contributor III

3 years and no answer to this???

0 Kudos