AnsweredAssumed Answered

multipleDefine error in dojoLoader

Question asked by christophertaplogic on Jan 7, 2015
Latest reply on Jul 10, 2018 by csgeosol1

I am working on a js application that uses ArcGIS JS (currently targeting 3.8, referencing through the arcgis cdn).  We have found an issue during internal testing where when the app loads and the dojo require/define chain resolves, periodically the app will fail to load with "multipleDefine" errors being thrown from dojoLoader in esri init.js.  We have a single computer running IE 10 that can easily replicate the error in one or two loads of the page.  Testing on another computer running IE 10 did not provide a replication of the issue.  I have tested on IE 11 as well and was able to replicate a few times over many loads of the app.  This hasn't been enough to go on to track down the cause.

 

We have a number of custom modules setup with the standard "define" structure.  It appears that when one of these modules loads, a group of the references in the define block fail with the multipleDefine errors.  As an example, there is a custom module that handles the setup and use of a BasemapGallery.  In the case of this module, the errors may occur when loading  'esri/dijit/BasemapGallery', 'esri/dijit/BasemapLayer', 'esri/dijit/Basemap', among others.  These 3 references in particular are only made within this single module in our entire app.

 

Any thoughts about what could be causing this issue?

 

Thanks

 

define([
    'dojo/_base/declare',
    'dijit/_WidgetBase',
    'dijit/_TemplatedMixin',
    'dijit/_WidgetsInTemplateMixin',
    'dojo/_base/lang',
    'dijit/form/DropDownButton',
    'dijit/DropDownMenu',
    'dijit/MenuItem',
    'dojo/_base/array',
    'dojox/lang/functional',
    'dojo/text!./Basemaps/templates/Basemaps.html',
    'esri/dijit/BasemapGallery',
    'esri/dijit/BasemapLayer',
    'esri/dijit/Basemap',
    'dijit/registry',
    'esri/layers/ArcGISTiledMapServiceLayer'
], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, lang, DropDownButton, DropDownMenu, MenuItem, array, functional, template, BasemapGallery, BasemapLayer, Basemap, registry, ArcGISTiledMapServiceLayer) {

    //anonymous function to load CSS files required for this module
    (function () {
        var css = [require.toUrl("gis/dijit/Basemaps/css/Basemaps.css")];
        var head = document.getElementsByTagName("head").item(0),
            link;
        for (var i = 0, il = css.length; i < il; i++) {
            link = document.createElement("link");
            link.type = "text/css";
            link.rel = "stylesheet";
            link.href = css[i].toString();
            head.appendChild(link);
        }
    } ());

    var customBasemaps = {
        //SNIP     
    };

    var agolBasemaps = {
        //SNIP   
    };

    // main basemap widget
    return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
        templateString: template,
        widgetsInTemplate: true,
        mode: "agol",
        title: "Basemaps",
        mapStartBasemap: "hybrid",
        basemapsToShow: ["hybrid", "satellite", "streets", "topo", "gray", "oceans", "national-geographic", "osm"],
        validBasemaps: [],
        postCreate: function () {
            //SNIP
        },
        startup: function () {
            this.inherited(arguments);
            if (this.mode === "custom") {
                this.gallery.select(this.mapStartBasemap);
            } else {
                this.map.setBasemap(this.mapStartBasemap);
            }
        }
    });
});

Outcomes