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 for JavaScript. . 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:
<SPAN class="token function">require</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"esri/map"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"app/knockout-latest"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN>Map<SPAN class="punctuation token">,</SPAN> ko<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>My index.html is has the dojoConfig specified as such:
script type<SPAN class="operator token">=</SPAN><SPAN class="string token">"text/javascript"</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="keyword token">var</SPAN> dojoConfig <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN>
baseUrl<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'.'</SPAN><SPAN class="punctuation token">,</SPAN>
deps<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"app/knockout-latest"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'app/main'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'app/date'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>
packages<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN>
<SPAN class="string token">'app'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'dijit'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'dojo'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'dojox'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'dstore'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'dgrid'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'xstyle'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'put-selector'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'esri'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'js'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'dojo-bootstrap'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'lib'</SPAN>
<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>
parseOnLoad<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">true</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="operator token"><</SPAN><SPAN class="operator token">/</SPAN>script<SPAN class="operator token">></SPAN>
<SPAN class="operator token"><</SPAN><SPAN class="operator token">!</SPAN><SPAN class="operator token">--</SPAN>Dojo loader <SPAN class="operator token">--</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="operator token"><</SPAN>script src<SPAN class="operator token">=</SPAN><SPAN class="string token">"dojo/dojo.js"</SPAN><SPAN class="operator token">></SPAN><SPAN class="operator token"><</SPAN><SPAN class="operator token">/</SPAN>script<SPAN class="operator token">></SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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!