![]() ![]() There may be times when you do want to reference a script directly and not conform to the "baseUrl + paths" rules for finding it. All of these capabilities allow you to use smaller strings for scripts as compared to traditional tags. RequireJS will automatically add it when translating the module ID to a path. RequireJS also assumes by default that all dependencies are scripts, so it does not expect to see a trailing ".js" suffix on module IDs. If there is no explicit config and data-main is not used, then the default baseUrl is the directory that contains the HTML page running RequireJS. Or, baseUrl can be set manually via the RequireJS config. This example will end up with a baseUrl of scripts: The data-main attribute is a special attribute that require.js will check to start script loading. The baseUrl is normally set to the same directory as the script used in a data-main attribute for the top level script to load for a page. RequireJS loads all code relative to a baseUrl. As part of that, it encourages using module IDs instead of URLs for script tags. While it can also run fast and optimize well, the primary goal is to encourage modular code. Other than this, there is really not a lot of information floating around that really explains the issue well.RequireJS takes a different approach to script loading than traditional tags. You can read here about the error, although its only a little snippet about it, just search mulipleDefine on this page: The Dojo Loader - The Dojo Toolkit - Reference Guide. However I have noticed the error messages can be misleading, especially looking at the call stack because it may start loading some dojo modules, but then the 3rd party library tries to load, either from the script tag or through a define/require call or both, and it fails and you now have a call stack listing all these dojo modules when the error is really somewhere else. I dont think I have ever had the issue be with a dojo or esri module, its usually a 3rd party library. multipleDefine errors happen generally happen from loading modules via script tags and not the amd loader provided by dojo, or esri in this case, which results in a sort of race condition unless you load them how Dennis is suggesting. Not sure why it would point to something like the DropDownMenu. Load those scripts in the header and the esri javascript api at the end once those scripts have loaded. It may be easier to just use what Dennis is suggesting. ], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, lang, DropDownButton, DropDownMenu, MenuItem, array, functional, template, BasemapGallery, BasemapLayer, Basemap, registry, ArcGISTiledMapServiceLayer ) ) Īhh ok. These 3 references in particular are only made within this single module in our entire app.Īny thoughts about what could be causing this issue?ĭefine ([ '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' In the case of this module, the errors may occur when loading 'esri/dijit/BasemapGallery', 'esri/dijit/BasemapLayer', 'esri/dijit/Basemap', among others. As an example, there is a custom module that handles the setup and use of a BasemapGallery. It appears that when one of these modules loads, a group of the references in the define block fail with the multipleDefine errors. ![]() We have a number of custom modules setup with the standard "define" structure. This hasn't been enough to go on to track down the cause. ![]() I have tested on IE 11 as well and was able to replicate a few times over many loads of the app. Testing on another computer running IE 10 did not provide a replication of the issue. We have a single computer running IE 10 that can easily replicate the error in one or two loads of the page. 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. I am working on a js application that uses ArcGIS JS (currently targeting 3.8, referencing through the arcgis cdn). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |