3

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!

Web Devie
  • 1,207
  • 1
  • 13
  • 30
luso
  • 2,812
  • 6
  • 35
  • 50
  • I'm making a test project with exactly the same structure but instead loading all the widgets of my own, I just include some dependendies and it works fine. It loads the file correctly and loads the app (hyperfast by the way) so I guess is some kind of error into the code. But while compiling the build system found some JS errors in the code so I guess if there would be any error it would be still telling to me right? If it can download the whole file why is not loading the app? – luso Nov 22 '11 at 09:04
  • could it be some issue with i18n files? I don't really understand why it's creating the nls folder,... – luso Nov 22 '11 at 09:11
  • So, here the situation: Normally that error (could not load...) appears if: Can't find the file (not this one, it downloads it) You forget to dojo.provide() the file (not this, is the first line) There is an error in the code: I guess it must be that, but when the app is not builded it works fine and I guess dojo builder is not introducing errors... – luso Nov 24 '11 at 10:37

1 Answers1

0

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)

ben
  • 3,558
  • 1
  • 15
  • 28