Building dojo app: layer downloads but not load

721 views Asked by At

I'm trying to built a Dojo app using the building system it provides. I have a main index.php file loading the dojo, dijit and dojox libraries

The structure of the project is something like:

--root
  --_profile
  --_release
  --dojo-1.3.2-src
    -- dijit
    -- dojo
    -- dojox
    -- util
  --myApp
    --init.js
    --folders_with_all_my_code
  --index.php

In the _profile folder I have my myApp.profile.js including this:

dependencies = {

    stripConsole    : 'all',
    action      : 'clean,release',
    optimize    : 'shrinksafe',
    releaseName : 'myApp',
    localeList  : 'fr,es,it',

    layers: [
        {
            name        : "../app/init.js",
            resourceName    : "myApp.init",
            dependencies    : [
                  "myApp.init"
            ]
        }
    ],

    prefixes: [
        [ "dijit",  "../dijit" ], 
        [ "dojox",  "../dojox" ],
        [ "app",    "../../app" ]
    ]

};

I'm launching this script to build up the application:

cd ../dojo-1.3.2-src/util/buildscripts

./build.bat profileFile=../../../_profile/myApp.profile.js releaseDir=../../../_release

It builds ok and set the _release dir as expected:

--root
  --_profile
  --_release
    -- myapp
       -- app
          -- all_my_code
          -- nls
          -- init.js.uncompressed.js
          -- init.js (a 2Mb file with all compressed dependencies)
       -- dijit
       -- dojo
       -- dojox
       -- util
  --dojo-1.3.2-src
    -- dijit
    -- dojo
    -- dojox
    -- util
  --myApp
    --
  --index.php

In the index.php file, before building I include this:

var djConfig = {
    parseOnLoad: true, 
    usePlainJson: true,
    modulePaths : { 'app' : '../../myApp/app' }
};

script ... src="/dojo-1.3.2-src/dojo/dojo.js"> ... /script
script ... dojo.require('app.init'); ... /script

and works fine. But once I have my layers compiled I'm supposed to change the script pointing to dojo.js to point the newly created one and to point the dojo.require to the new compressed layer. Since in the profile I've specified than the location of the layer is the same as the original init,js file, I get this:

var djConfig = {
    parseOnLoad: true, 
    usePlainJson: true,
    <s>modulePaths : { 'app' : '../../myApp/app' }</s>
};

<s>script ... src="/dojo-1.3.2-src/dojo/dojo.js"> ... /script</s>
<s>script ... dojo.require('app.init'); ... /script</s>

script ... src="/_release/myApp/dojo/dojo.js"> ... /script
script ... dojo.require('app.init'); ... /script

Actually when I launch the app it loads correctly just ONE file so I guess everything went OK with the paths. Actually in the Firebug log I can see the GET request and if I expand it I can see all the app compressed. However just after loading it it launch an exception:

Could not load 'app.init'; last tried '../../myApp/app/init.js'

I'm not sure but it doesn't seems to be a problem with the paths, since it's downloading the file init.js, so now I'm a bit confused.

Any idea?

Thanks!

1

There are 1 answers

0
ben On

Try to play with modulePaths or with dojoConfig.baseUrl

You could also try customBase property so you only have to load your dojo.js and it will contains everything, even your app. (https://dojotoolkit.org/reference-guide/1.10/build/customBase.html)