Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dojo 1.8 and builds (or lack thereof)

I really have no idea where to begin.

I've gone through every tutorial, article, and blog post to try and get the one thing that dojo has going for it working, and never have I had such a problem getting something to work, at least just a little. I've found flame wars over documentation as well as people with working scripts, but nothing posted or outlined. At SO, I've found that it's a very common issue, but no resolve half the time.

Disclaimer: Forget 1.6. I never used 1.6. Therefore, half my resources found online are void, and so is my book. Here we go.

Question 1

What's the difference between a LOT of posts about using this format:

dependencies = {
    stripConsole: "all",
    action: "release",
    optimize: "shrinksafe",
    // Omitted options...
    layers: [{
        name: "dojo.js",
        customBase : true,
            dependencies: [ 
              "dojox.gauges.AnalogNeedleIndicator",
              "myApp.smartmix"]           
        }
    ],
    prefixes: [
        [ "dijit", "../dijit" ], 
        [ "dojox", "../dojox" ],
        [ "myApp", "../../../myApp" ]
    ]
};

...vs this format:

var profile = {
    basePath: './',
    stripConsole: 'all',
    selectorEngine: 'lite',
    layers: {
        'dojo/dojo': {
            include: ['dojo/dojo', 'dojo/domReady', 'dojo/_base/declare'],
            boot: true,
            customBase: true
        },
        'dgrid/dgrid': {
            include: ["dgrid/List", "dgrid/OnDemandGrid", "dgrid/Selection", "dgrid/Keyboard", "dgrid/test/data/perf"]
        }
    }
    // static-has-features removed
};

There are two very important differences in the layers object between the two that either A) Everyone seems to just "know" about without any reason or rational, or B) People just seem to "know". I have yet to find anything written about the differences between the two syntax (syntaxis? syntax's?) that have anything to do with the new AMD structure and the rewrite of the build system.

The closest I've seen is the object name doesn't matter, nor does the declaration. It can be a "global" variable (omission of the var keyword), or not, the name doesn't matter so long as the object returned contains the necessary information.

The second format gives me an "unexpected String" error and fails 99% of the time, even with copy/pasted profiles.

Question 2

What exactly is required?! The Dojo's documentation says a package.json AND a appName.profile.js file is REQUIRED, but in all the tutorials I've seen, only the profile is required, and used, for that matter. Therefore, half the information at the Dojo's main website about building isn't used. So........?

The Dojo site says to use the src release for builds. A guy at Nabble said you must get the svn version as the src version is already "built".

... so who's on first?

Question 3

Does anyone, anyone at all, have a working directory structure and profile.js file they'd care to share? I have tried EVERYTHING. And I do mean EVERYTHING, to get a build. One suggestion was to use an empty profile object. That works, and it's useless.

Another suggestion was to use the dojo boilerplate build. What good is a template if any alteration breaks it? What have you tried is a moot point as I've tried, in the words of Tony Stark, "every permutation of every known [javascript object variation]. Nothing works."

I'm losing faith quickly. Not because I can't figure it out after hours of trial-and-failure, but because a lot of people are in the same boat. It's sinkin'.

Final Question

So, my last request is, can someone, PLEASE shed some light on how this build system works, and not just links to the already-purpled-out-read-and-re-read links one would find on Google?

How... do you... configure a Dojo build profile... and execute it... without error?! It's insane how bad this system is both A) documented and B) implemented, and while I'm at it C) taught. It's exhausting.

Some of the (many) sites I've visited:

  • Nabble SVN vs. SDK
  • SitePen tutorial that... doesn't produce.
  • One "Boilerplate" Profile (from SitePen)
  • Dojo Boilerplate Profile (github)
  • Dojo Tutorial

Update

Many thanks to @xesxz and @Craig Swing. After a few minor things, I've got a build profile that chunks away and gives me what I need!

like image 538
Phix Avatar asked Mar 14 '13 08:03

Phix


1 Answers

What's the difference between a LOT of posts about using this format...

Your first example is for the pre Dojo 1.7 build. If you are using 1.7 or later you want your second example.

The Dojo site says to use the src release for builds. A guy at Nabble said you must get the svn version as the src version is already "built".

... so who's on first?

You need the SDK from http://dojotoolkit.org/download/

On the page it is labeled as "Source". This contains a util directory that has all the build scripts, as well as the other directories that contain the non-built versions of the dojo files.

Does anyone, anyone at all, have a working directory structure and profile.js file they'd care to share?

The projects I am working on have similar structure to what @xesxz posted. But, I have tried using boot: true, customBase: true with no success. The following is my profile. (My directory structure is a bit different, so the paths don't match what @xesxz posted).

In my app I will include the following

  • dojo/dojo.js
  • myCore/core.js
  • myAppModuleX/app.js, where X is the specific module I am using on the page.

core.profile.js (for building)

var profile = (function(){
     var coreRequires = [
        "dojo/_base/declare",
        "dojo/_base/fx",
        "dojo/_base/lang",
        "dojo/currency",
        "dojo/fx",
        "dojo/number",
        "dojo/on",
        "dojo/query",

        "dijit/dijit",

        "myCore/ACoreWidget"
    ];

    return {
        basePath:       "./dojo-release-1.8.3-src",
        releaseDir:     "../../DEV-REL",
        action:         "release",
        cssOptimize:    "comments",
        selectorEngine: "acme",

        packages:[{
            name: "dojo",
            location: "dojo"
        },{
            name: "dijit",
            location: "dijit"
        },{
            name: "dojox",
            location: "dojox"
        },{
            name: "myCoreModule",
            location: "../myCore"
        },{
            name: "myAppModule1",
            location: "../myAppModule1"
        },{
            name: "myAppModule2",
            location: "../myAppModule2"
        }],

        layers: {
            "myCore/core": {
                include:    coreRequires
            },

            "myAppModule1/app": {
                include:    [
                    "myAppModule1/WidgetX"
                ],
                exclude: coreRequires
            },

            "myAppModule2/app": {
                include:    [
                    "myAppModule2/WidgetY"
                ],
                exclude: coreRequires
            }
        }
    };
})();

How... do you... configure a Dojo build profile... and execute it... without error?

I use node to build. This gets executed in the directory that contains the build profile.

node dojo-release-1.8.3-src/dojo/dojo.js load=build --profile core.profile.js --release --version=1.8.3

My recommendation is to try to complete a build with a single custom widget that is very simple. If that works, then your real widgets

Regarding unexpected String,

  • Are all of your widgets using the new AMD syntax?
  • You have dgrid, but I believe that has dependencies on put-selector and xStyle
like image 75
Craig Swing Avatar answered Sep 18 '22 14:09

Craig Swing