Skip to content

Commit

Permalink
first draft of dojox/app build support
Browse files Browse the repository at this point in the history
  • Loading branch information
cjolif committed Oct 18, 2012
1 parent f7375b8 commit ac8e05a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
18 changes: 18 additions & 0 deletions build/buildControlApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
define(["build/buildControlDefault"], function(bc){

This comment has been minimized.

Copy link
@wkeese

wkeese Dec 1, 2012

Contributor

This line is breaking the API doc parser. There is no package called "build". Only dojo, dijit, and dojox. Should this be a relative path?

This comment has been minimized.

Copy link
@cjolif

cjolif Dec 1, 2012

Author Contributor

This code is not really meant to go trough the doc parser. These are extensions to Dojo build system (utils) not extensions to dojo, dijit, dojox.

This comment has been minimized.

Copy link
@wkeese

wkeese Dec 2, 2012

Contributor

Hmm OK, I guess we need to add the dojox/app/build directory to the list of modules for the doc parser to ignore.

// module:
// dojox/app/build/buildControlApp
// summary:
// This module extend default build control module to add dojox/app build support
bc.transforms["depsAppConfig"] = ["dojox/app/build/depsAppConfig", "read"];
// add the job at the right place in default control
bc.transformJobs.splice(bc.transformJobs.length - 2, 0, [
// json dojo app config files needs to go through depsAppConfig
function(resource, bc){
// parse all JSON files (some might not be app config but
// we will ignore them in the transform
return /\.json$/.test(resource.src);
},
["read", "depsAppConfig", "write"]
]);
return bc;
});
51 changes: 51 additions & 0 deletions build/depsAppConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
define([
"build/buildControl",
"dojox/json/ref"
], function(bc, json){
return function(resource){
var mids = [],
str = resource.text;

try{
var config = json.fromJson(str);
}catch(e){
}

if(!config){
return;
}

if(config.dependencies){
mids = mids.concat(config.dependencies);
}
if(config.controllers){
mids = mids.concat(config.controllers);
}
if(config.modules){
mids = mids.concat(config.modules);
}

// Iterate through the layers, identify those that contain this resource.mid,
// remove it from the include array and then add this resource's includes
for(var mid in bc.amdResources){
if(bc.amdResources[mid].layer){ // This resource is a layer
var includes = bc.amdResources[mid].layer.include,
idx = includes.indexOf(resource.mid);
// Bitwise operator that returns true if the layer contains this resource
if(~idx){
// Remove this resources mid from the layer's include array
includes.splice(idx, 1);
mids.forEach(function(dep){
// Uniquely add appropriate mids to the layer's include array
if(!(/^(require|exports|module)$/.test(dep))){
if(!~includes.indexOf(dep)){
includes.push(dep);
}
}
});
}
}
}

};
});

0 comments on commit ac8e05a

Please sign in to comment.