I am trying to use the Esri ArgGis JavaScript API, which is loaded by Dojo, using dojo.require
. I have an existing modular AMD/requirejs Typescript application that I need to integrate this code into. At the top of my initial TS file, I import several modules:
import tracer = module('../classes/trace');
import pubsub = module('../classes/pubsub');
import masker = module('../classes/masker');
// etc.
This was working fine, but now that I have added the ArcGis code, instead of resolving the relative path within my application, require.js has picked up a baseUrl from the Esri site, and tries to load:
http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/classes/trace.js
// etc.
Resulting in a string of 404 responses and script errors.
How can I fix this?
I've tried setting the requirejs baseUrl in the head of my html file before loading the first document that loads modules:
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3"></script>
<script type="text/javascript" src="/content/client/libs/require.js"></script> <!-- data-main="/content/client/hop/hop.app" -->
<script type="text/ecmascript">
require.config({
baseUrl: "/Content/client/hop/"
});
</script>
<script src="~/Content/client/hop/hop.app.js"></script>
But this fails, throwing an exception that require has no method config.
(NB If I reverse the order in the head of the html document so that the arcgis api comes last in the load sequence then I get the opposite problem - my local files all work fine but dojo and the mapping api fail because they are looking for paths relative to my site when they should be searching on the argis server).