Skip to content

Commit

Permalink
Make sure there are no requirejs build artifacts, and show an example…
Browse files Browse the repository at this point in the history
… that turns off closure minification.
  • Loading branch information
jrburke committed Apr 6, 2010
1 parent 3cb2945 commit 5b9572e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
16 changes: 14 additions & 2 deletions util/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ load('util/requirejs/build/jslib/fileUtil.js');
buildDoc: 'Builds a version of XUI. Example commands:\n' +
'\t\tThis build uses the build profile util/profiles/enchilada.js\n' +
'\t\t> build.sh build profile=enchilda\n\n' +
'\t\tThis build uses a profile with Closure minification off\n' +
'\t\t> build.sh build profile=enchilda optimize=none\n\n' +
'\t\tThis build defines a name for the build file and what files to include\n' +
'\t\t> build.sh build out=lib/xui-basedom.js include=base,core/dom',
build: function (args) {
//See if there is a profile arg, and if so get it and remove
//the option from the other build options.
var profile, hasBaseUrl = false, i, arg;
var profile, hasBaseUrl = false, hasSkipModuleInsertion = false, i, arg;
//Go backwards because when the slice happens do not want to
//mess up traversing the options.
for (i = args.length - 1; i > -1 && (arg = args[i]); i--) {
Expand All @@ -62,6 +64,8 @@ load('util/requirejs/build/jslib/fileUtil.js');
args.splice(i, 1);
} else if (arg.indexOf("baseUrl=") === 0) {
hasBaseUrl = true;
} else if (arg.indexOf("skipModuleInsertion=") === 0) {
hasSkipModuleInsertion = true;
}
}

Expand All @@ -73,7 +77,15 @@ load('util/requirejs/build/jslib/fileUtil.js');
args.unshift('util/requirejs/build');

//If no baseUrl, add it on now.
args.push('baseUrl=src/');
if (!hasBaseUrl) {
args.push('baseUrl=src/');
}

//Do not want requirejs to insert placeholder modules for ones
//that do not use require syntax
if (!hasSkipModuleInsertion) {
args.push('skipModuleInsertion=true');
}

//Call RequireJS build
build(args);
Expand Down
14 changes: 8 additions & 6 deletions util/requirejs/build/jslib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ var build;
}
if (includeRequire) {
requireContents = pragma.process(config.requireUrl, fileUtil.readFile(config.requireUrl), context.config);
if (require.buildFilePaths.length) {
if (require.buildFilePaths.length && !config.skipModuleInsertion) {
requireContents += "require.pause();\n";
}
buildFileContents += "require.js\n";
Expand Down Expand Up @@ -434,7 +434,7 @@ var build;
//If this is the first file, and require() is not part of the file
//and require() is not added later at the end to the top of the file,
//need to start off with a require.pause() call.
if (i === 0 && require.existingRequireUrl !== path && !includeRequire) {
if (i === 0 && require.existingRequireUrl !== path && !includeRequire && !config.skipModuleInsertion) {
fileContents += "require.pause()\n";
}

Expand All @@ -446,7 +446,7 @@ var build;
//after the module is processed.
placeHolderModName = require.buildFileToModule[path];
//If we have a name, but no defined module, then add in the placeholder.
if (placeHolderModName && !require.modulesWithNames[placeHolderModName]) {
if (placeHolderModName && !require.modulesWithNames[placeHolderModName] && !config.skipModuleInsertion) {
fileContents += 'require.def("' + placeHolderModName + '", function(){});\n';
}

Expand All @@ -457,19 +457,21 @@ var build;
fileContents += pluginContents;
buildFileContents += pluginBuildFileContents;
pluginContents = "";
fileContents += "require.pause();\n";
if (!config.skipModuleInsertion) {
fileContents += "require.pause();\n";
}
}

//If the file contents had a require.resume() we need to now pause
//dependency resolution for the rest of the files. Multiple require.pause()
//calls are OK.
if (needPause) {
if (needPause && !config.skipModuleInsertion) {
fileContents += "require.pause();\n";
}
}

//Resume dependency resolution
if (require.buildFilePaths.length) {
if (require.buildFilePaths.length && !config.skipModuleInsertion) {
fileContents += "\nrequire.resume();\n";
}

Expand Down

0 comments on commit 5b9572e

Please sign in to comment.