Widget - RequireJS - Handling Library Dependencies

0
Hi What is the recommended way to handle library dependencies in Mendix widgets? Is this the correct way to do it, does the order of the importing matter, etc... For example for importing JointJS   require( { packages: [ { name: 'jquery', location:'../../widgets/MxJointJs/lib', main: 'jquery-1.11.2' }, { name: 'lodash', location:'../../widgets/MxJointJs/lib/lodash-3.10.1', main: 'lodash' }, { name: 'backbone', location:'../../widgets/MxJointJs/lib/backbone-1.3.3', main: 'backbone' }, { name: 'underscore', location:'../../widgets/MxJointJs/lib/underscore-1.9.1', main: 'underscore' }, { name: 'joint', location:'../../widgets/MxJointJs/lib/joint-2.1.0', main: 'joint' } ], }, [ "dojo/_base/declare", "mxui/widget/_WidgetBase", "dijit/_TemplatedMixin", "mxui/dom", "dojo/dom", "dojo/dom-prop", "dojo/dom-geometry", "dojo/dom-class", "dojo/dom-style", "dojo/dom-construct", "dojo/_base/array", "dojo/_base/lang", "dojo/text", "dojo/html", "dojo/_base/event", "jquery", "lodash", "backbone", "underscore", "joint", "dojo/text!MxJointJs/widget/template/MxJointJs.html" ], function( declare, _WidgetBase, _TemplatedMixin, dom, dojoDom, dojoProp, dojoGeometry, dojoClass, dojoStyle, dojoConstruct, dojoArray, lang, dojoText, dojoHtml, dojoEvent, _jQuery, lodash, backbone, underscore, joint, widgetTemplate ){ "use strict"; var $ = _jQuery.noConflict(true); return declare( "MxJointJs.widget.MxJointJs", [ _WidgetBase, _TemplatedMixin ],{ templateString: widgetTemplate, widgetBase: null, // Internal variables. _handles: null, _contextObj: null, constructor: function () { this._handles = []; }, postCreate: function () { logger.debug(this.id + ".postCreate"); console.log(joint); }, update: function (obj, callback) { logger.debug(this.id + ".update"); this._contextObj = obj; this._updateRendering(callback); }, resize: function (box) { logger.debug(this.id + ".resize"); }, uninitialize: function () { logger.debug(this.id + ".uninitialize"); }, _updateRendering: function (callback) { logger.debug(this.id + "._updateRendering"); if (this._contextObj !== null) { dojoStyle.set(this.domNode, "display", "block"); } else { dojoStyle.set(this.domNode, "display", "none"); } this._executeCallback(callback, "_updateRendering"); }, // Shorthand for running a microflow _execMf: function (mf, guid, cb) { logger.debug(this.id + "._execMf"); if (mf && guid) { mx.ui.action( mf, { params: { applyto: "selection", guids: [guid] }, callback: lang.hitch( this, function (objs) { if (cb && typeof cb === "function") { cb(objs); } } ), error: function (error) { console.debug(error.description); } }, this ); } }, // Shorthand for executing a callback, adds logging to your inspector _executeCallback: function (cb, from) { logger.debug(this.id + "._executeCallback" + (from ? " from " + from : "")); if (cb && typeof cb === "function") { cb(); } } } ); } ); //require(["MxJointJs/widget/MxJointJs"]); Here lodash, backbone and underscore were imported to get joint to load in. Object { version: "2.1.0", config: {…}, dia: {…}, ui: {}, layout: {…}, shapes: {…}, format: {}, connectors: {…}, highlighters: {…}, routers: {…}, … } If I require another library and it interferes with lodash, backbone, or underscore, which is not directly used in the widget by used by JointJS, what would the resolution be? Just trying to get a better understanding of this
asked
0 answers