Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dojo build 1.7 built packages does not work

I'm at the beginning of building my project and I get some errors that couldn't realize why they are being occured.

You can see contents of my app.profile.js file below. I execute "build profile=../../app.profile.js -r" this line from command prompt and I get no error after the process is done. My problem is if I copy the release(built) version of these packages to the place where the unbuilt versions exist, I get too many javascript errors like "Error: multipleDefine". Even if I copy only dojo, dojox and dijit folders, same errors are keep occuring.

When I look the differences between built and unbuilt of two js files, (for example dojo/Deferred) the only difference I realize is this:

//built 
define("dojo/Deferred", [ 
        "./_base/lang", 
        "./promise/CancelError", 
        "./promise/Promise" 
], function( 

define([ 
        "./_base/lang", 
        "./promise/CancelError", 
        "./promise/Promise" 
], function( 

So I'm a little bit stucked at the beginning. I want to try using layers to reduce http requests as soon as possible but I need some help about the situation I mentioned. Any help will be greatly appreciated, thanks.

app.profile.js:

var profile = { 
    basePath: "..", 
    layerOptimize: "shrinksafe.keepLines", 
    optimize: "shrinksafe", 
    releaseDir: "./release", 
    hasReport: true, 

    packages: [ 
        { 
            name: "dojo", 
            location: "./dojo" 
        }, 

        { 
            name: "dijit", 
            location: "./dijit" 
        }, 

        { 
            name: "app", 
            location: "./app" 
        }, 
        { 
            name: "dtk", 
            location: "./dtk" 
        }, 
        { 
            name: "dojox", 
            location: "./dojox" 
        } 
    ], 

    layers: { 
        "app/layers/core": { 
            include: [ 
                        "dojo/_base/declare", 
                        "dtk/core/ILifeCycle", 
                        "dtk/core/AppConfig", 
                        "dtk/core/TopicContext", 
                        "dtk/core/NavigationContext", 
                        "dojo/require", 
                        "dojo/_base/Deferred", 
                  "dojo/DeferredList", 
                        "dojo/_base/lang" 
            ] 
        }, 
        "app/layers/appcontext": { 
            include: [ 
                "dtk/core/AppContext" 
            ], 
            exclude: [ 
                "app/layers/core" 
            ] 

        } 

    } 
};
like image 460
facot Avatar asked Feb 20 '23 06:02

facot


2 Answers

The Dojo builder will add a module identifier to every module definition unless you tell it not to. This can produce the multipleDefine error.

From the builder documentation:

insertAbsMids (default = undefined)

  • [truthy] Causes the transform to ensure that every AMD define application includes a module identifier argument.
  • [falsy] The transform does nothing to the module identifier argument in define applications. In particular, a falsy value doe not cause the transform to remove a module identifier argument that exists in the source code.

I was having exactly the same problem until I added insertAbsMids:false to my profile.

eg:

var profile = {
    basePath: "./",
    releaseDir: "release",
    action: "release",

    layerOptimize: "shrinksafe",
    optimize: "shrinksafe",
    cssOptimize: "comments",
    mini: false,
    insertAbsMids: false,

    packages: [
        { name: "dijit", location :"dijit" },
        { name: "dojox", location :"dojox" },
        { name: "dojo", location :"dojo" }
    ]
}
like image 164
Stephen Simpson Avatar answered Feb 27 '23 23:02

Stephen Simpson


If your problem is with the id that gets created in the AMD module define(id, [deps], factory).. I was having a similar issue, I had to manually remove all the id's on the compressed files:

//built 
define([ 
        "./_base/lang", 
        "./promise/CancelError", 
        "./promise/Promise" 
], function()

OR, I had to require the module using the id instead.

For example, I was requiring a module:

require(["app/Dialog"])

which was different than the id added.

require(["demo/app/Dialog"])

It was the only way I got it to work. Anyone else knows how to remove the id or reason why we should always have an id? Not sure if this is relavent to your question, but since you showed the differences.

like image 26
Luis R. Avatar answered Feb 27 '23 23:02

Luis R.