Dojo build and knockout failing with multipleDefine error once built

862
1
11-14-2016 01:15 PM
Jay_Gregory
Occasional Contributor III

I am using 3.16 of the ArcGIS API, downloaded locally via the bower / grunt instructions located GitHub - Esri/jsapi-resources: A collection of useful resources for developers using the ArcGIS API ... .  I have built my application in development using Knockout JS and it works like a charm.  I load the Knockout library in the require section of my main javascript file: 

require(["esri/map", "app/knockout-latest"], function (Map, ko) {.....‍‍‍

My index.html is has the dojoConfig specified as such:

script type="text/javascript">
 var dojoConfig = {
 baseUrl: '.',
 deps: ["app/knockout-latest",'app/main', 'app/date'],
 packages: [
 'app',
 'dijit',
 'dojo',
 'dojox',
 'dstore',
 'dgrid',
 'xstyle',
 'put-selector',
 'esri',
 'js',
 'dojo-bootstrap',
 'lib'
 ],
 parseOnLoad: true
 };
 </script>
 <!--Dojo loader -->
 <script src="dojo/dojo.js"></script>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

So my app works perfectly in development, but once I use grunt to build the application, it breaks.  The build completes successfully (I use the default build.profile.js from the GitHub repo), but I get a multipleDefine error in dojo.js.  I've tried everything.  

If I don't include it as a dependency in my dojoConfig, I get I.observableArray is not a function in dojo.js, and then a multiple define error.  

I don't know how to fix this, other than to remove it from the build process and AMD load process all together, load it with a separate script tag and don't use it in the require block in my main js file.  Has anyone run into this issue before with the dojo build / loader and knockout?

Thanks!

0 Kudos
1 Reply
ReneRubalcava
Frequent Contributor

I assume app/main has this in it

require(["esri/map", "app/knockout-latest"], function (Map, ko) {.....

If that's the case, try not adding it to the deps of the profile, since it's not really a dependency because the main file loads it.

deps is used to load files immediately after Dojo loads, it would typically only be a single file, like an app/main, but include files that may add globals as well.

0 Kudos