Search code examples
dojodurandalesri

Using Durandal dojoConfig and ESRI Maps


I'm trying to get ESRI maps working with Durandal and came across this link in the Durandal docs DurandalEsri

This seems to work but now Durandal is having problems finding some of my .js files. If I leave the following dojoConfig out my scripts are found but then the maps won't work.

`var dojoConfig = {
    baseUrl: './',
    async: true,
    tlmSiblingOfDojo: true,
    parseOnLoad: false,
    aliases: [['text', 'dojo/text']],
    packages: [
        { name: 'esri', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri' },
        { name: 'dojo', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojo' },
        { name: 'dojox', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojox' },
        { name: 'dijit', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit' },
        { name: 'durandal', location: 'App/durandal' },
        { name: 'views', location: 'App/views' },
        { name: 'viewmodels', location: 'App/viewmodels' },
        { name: 'lib', location: 'App/lib' }
    ]
};`

My app structure looks like this:

  • App
    • durandal
    • lib
    • services
    • viewmodels
    • views

So in my shell.js file if I try to pass in 'lib/config' I get a 404 because it tried to find the config file at localhost/lib/config.js instead of localhost/dashboard/app/lib/config.js

If I pass 'dashboard/app/lib/config' to shell.js the file will be found, but it doesn't seem like I should have to specify the entire path, since 'durandal/system' and anything else under the 'durandal' folder get found correctly.

Any ideas???


Solution

  • So for my scenario of Durandal + Esri + Dojo, I had to leave out the require.js file that is included with Durandal and use the dojo AMD loader. Unfortunately I have no idea what future problems this might cause. More info can be found here