Permalink
Browse files

First working test of mainConfigFile, and code changes to match.

  • Loading branch information...
1 parent 88d149b commit e4c285769735abb40dbea6337b0d67c926312191 @jrburke jrburke committed Jan 23, 2012
View
@@ -8,6 +8,7 @@ build/tests/lib/namespace/foo.js
build/tests/lib/plugins/main-built.js
build/tests/lib/plugins/main-builtPluginFirst.js
build/tests/lib/dotpackage/built
+build/tests/lib/mainConfigFile/basic/main-built.js
build/tests/lib/moduleThenPlugin/built.js
build/tests/lib/nameInsertion/built.js
build/tests/lib/nested/main-built.js
View
@@ -24,6 +24,16 @@
//baseUrl should be specified as relative to the appDir.
baseUrl: "./",
+ //By default all the configuration for optimization happens from the command
+ //line or by properties in the a config file, and configuration that was
+ //passed to requirejs as part of the app's runtime "main" JS file is *not*
+ //considered. However, if you prefer for the that "main" JS file configuration
+ //to be read for the build so that you do not have to duplicate the values
+ //in a separate configuration, set this property to the location of that
+ //main JS file. The first requirejs({}), require({}), requirejs.config({}),
+ //or require.config({}) call found in that file will be used.
+ mainConfigFile: '../some/path/to/main.js',
+
//Set paths for modules. If relative paths, set relative to baseUrl above.
//If a special value of "empty:" is used for the path value, then that
//acts like mapping the path to an empty file. It allows the optimizer to
View
@@ -625,10 +625,13 @@ function (lang, logger, file, parse, optimize, pragma,
mainConfigFile = config.mainConfigFile || buildFileConfig.mainConfigFile;
if (mainConfigFile) {
+ mainConfigFile = build.makeAbsPath(mainConfigFile, absFilePath);
mainConfig = parse.findConfig(mainConfigFile, file.readFile(mainConfigFile));
if (mainConfig) {
- //Need to mix in config from configMain first, and
- //all paths are relative to mainConfig.
+ //If no baseUrl, then use the directory holding the main config.
+ if (!mainConfig.baseUrl) {
+ mainConfig.baseUrl = mainConfigFile.substring(0, mainConfigFile.lastIndexOf('/'));
+ }
build.makeAbsConfig(mainConfig, mainConfigFile);
lang.mixin(config, mainConfig, true);
}
View
@@ -537,4 +537,21 @@ define(['build', 'env!env/file'], function (build, file) {
);
doh.run();
+ doh.register("mainConfigFileBasic",
+ [
+ function mainConfigFileBasic(t) {
+ file.deleteFile("lib/mainConfigFile/basic/main-built.js");
+
+ build(["lib/mainConfigFile/basic/tools/build.js"]);
+
+ t.is(nol(c("lib/mainConfigFile/basic/expected.js")),
+ nol(c("lib/mainConfigFile/basic/main-built.js")));
+
+ require._buildReset();
+ }
+
+ ]
+ );
+ doh.run();
+
});
@@ -0,0 +1,20 @@
+
+define('dep1',{
+ name: 'dep1'
+});
+
+define('dep2',{
+ name: 'dep2'
+});
+
+requirejs.config({
+ paths: {
+ 'dep2': 'sub/dep2'
+ }
+});
+
+requirejs(['dep1', 'dep2'], function () {
+
+});
+
+define("main", function(){});
@@ -0,0 +1,6 @@
+({
+ mainConfigFile: '../www/js/main.js',
+ name: 'main',
+ out: '../main-built.js',
+ optimize: 'none'
+})
@@ -0,0 +1,3 @@
+define({
+ name: 'dep1'
+});
@@ -0,0 +1,9 @@
+requirejs.config({
+ paths: {
+ 'dep2': 'sub/dep2'
+ }
+});
+
+requirejs(['dep1', 'dep2'], function () {
+
+});
@@ -0,0 +1,3 @@
+define({
+ name: 'dep2'
+});

0 comments on commit e4c2857

Please sign in to comment.