require.config({ baseUrl: "lib", paths: { "knockout": "//cdnjs.cloudflare.com/ajax/libs/knockout/3.0.0/knockout-min", "jquery": "//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min", "dojoMain": "arcgis_compact/js/dojo/dojo/dojo", "dojo": "arcgis_compact/js/dojo/dojo", "esri": "arcgis_compact/js/esri" }, shim: { "knockout": { exports: "ko" } } });
SO I'm working on getting esri geolocation library separated from using dojo and it's require modules to make it more compatible with my stack involving things that need to be shimmed. I've downloaded the arcgis_compact library and require js and defined my config as followsrequire.config({ baseUrl: "lib", paths: { "knockout": "//cdnjs.cloudflare.com/ajax/libs/knockout/3.0.0/knockout-min", "jquery": "//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min", "dojoMain": "arcgis_compact/js/dojo/dojo/dojo", "dojo": "arcgis_compact/js/dojo/dojo", "esri": "arcgis_compact/js/esri" }, shim: { "knockout": { exports: "ko" } } });
when I require certain modules I get some errors when dojo requires some of the base javascripts. Some of them seem to be dojo's require kicking in and not finding some of what I configured, others are missing modules all together.
Hi Daniel,
You will have to provide the URL for the hosted API.
for example
"dojoMain": "http://<yourhostedmachinename>/arcgis_compact/js/dojo/dojo/dojo",
"dojo": "http://<yourhostedmachinename>/arcgis_compact/js/dojo/dojo",
"esri": "http://<yourhostedmachinename>/arcgis_compact/js/esri"
let me know if this works.
Best Regards,
Manish
define('knockout', function() { return ko; });
The ArcGIS JavaScript API version of Dojo is an already built version of Dojo, so you cannot replace the Dojo loader with RequireJS. You can apparently use the RequireJS loader with Dojo, but only with the downloaded version and you can specify which loader to use (I have never done this, but that's my understanding).
So in short, you can't use RequireJS with the ArcGIS JS API.
Dojo doesn't provide a "shim" property in the config, but you can fake it likedefine('knockout', function() { return ko; });
require.config({ paths: { "dojo": "../dojo-release-1.9.1-src/dojo", "dijit": "../dojo-release-1.9.1-src/dijit", "dojox": "../dojo-release-1.9.1-src/dojox", "esri": "http://js.arcgis.com/3.8amd/js/esri", // NOTE: loading Dojo modules from esri CDN fails // have to use local copy of Dojo... for now // "dojo": "http://js.arcgis.com/3.8amd/js/dojo/dojo", // "dijit": "http://js.arcgis.com/3.8amd/js/dojo/dijit/", // "dojox": "http://js.arcgis.com/3.8amd/js/dojo/dojox/" } });