Skip to content

Commit 58b0f2e

Browse files
committed
Merge branch 'master' into onwrite
2 parents 39c6fea + 9924b21 commit 58b0f2e

File tree

5 files changed

+124
-49
lines changed

5 files changed

+124
-49
lines changed

build/jslib/build.js

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
* see: http://github.com/jrburke/requirejs for details
55
*/
66

7-
/*jslint regexp: false, plusplus: false, nomen: false, strict: false */
8-
/*global define: false, require: false */
7+
/*jslint plusplus: true, nomen: true */
8+
/*global define, require */
99

1010

1111
define([ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma',
1212
'env!env/load', 'requirePatch'],
1313
function (lang, logger, file, parse, optimize, pragma,
1414
load, requirePatch) {
15+
'use strict';
16+
1517
var build, buildBaseConfig,
1618
endsWithSemiColonRegExp = /;\s*$/;
1719

@@ -532,32 +534,25 @@ function (lang, logger, file, parse, optimize, pragma,
532534
* to the absFilePath passed in.
533535
*/
534536
build.makeAbsConfig = function (config, absFilePath) {
535-
var props, prop, i, originalBaseUrl;
537+
var props, prop, i;
536538

537539
props = ["appDir", "dir", "baseUrl"];
538540
for (i = 0; (prop = props[i]); i++) {
539541
if (config[prop]) {
540542
//Add abspath if necessary, make sure these paths end in
541543
//slashes
542544
if (prop === "baseUrl") {
543-
originalBaseUrl = config.baseUrl;
545+
config.originalBaseUrl = config.baseUrl;
544546
if (config.appDir) {
545547
//If baseUrl with an appDir, the baseUrl is relative to
546548
//the appDir, *not* the absFilePath. appDir and dir are
547549
//made absolute before baseUrl, so this will work.
548-
config.baseUrl = build.makeAbsPath(originalBaseUrl, config.appDir);
549-
//Set up dir output baseUrl.
550-
config.dirBaseUrl = build.makeAbsPath(originalBaseUrl, config.dir);
550+
config.baseUrl = build.makeAbsPath(config.originalBaseUrl, config.appDir);
551551
} else {
552552
//The dir output baseUrl is same as regular baseUrl, both
553553
//relative to the absFilePath.
554554
config.baseUrl = build.makeAbsPath(config[prop], absFilePath);
555-
config.dirBaseUrl = config.dir || config.baseUrl;
556555
}
557-
558-
//Make sure dirBaseUrl ends in a slash, since it is
559-
//concatenated with other strings.
560-
config.dirBaseUrl = endsWithSlash(config.dirBaseUrl);
561556
} else {
562557
config[prop] = build.makeAbsPath(config[prop], absFilePath);
563558
}
@@ -630,12 +625,13 @@ function (lang, logger, file, parse, optimize, pragma,
630625
var config = {}, buildFileContents, buildFileConfig, mainConfig,
631626
mainConfigFile, prop, buildFile, absFilePath;
632627

633-
lang.mixin(config, buildBaseConfig);
634-
lang.mixin(config, cfg, true);
635-
636628
//Make sure all paths are relative to current directory.
637629
absFilePath = file.absPath('.');
638-
build.makeAbsConfig(config, absFilePath);
630+
build.makeAbsConfig(cfg, absFilePath);
631+
build.makeAbsConfig(buildBaseConfig, absFilePath);
632+
633+
lang.mixin(config, buildBaseConfig);
634+
lang.mixin(config, cfg, true);
639635

640636
if (config.buildFile) {
641637
//A build file exists, load it to get more config.
@@ -697,6 +693,19 @@ function (lang, logger, file, parse, optimize, pragma,
697693
//args should take precedence over build file values.
698694
mixConfig(config, cfg);
699695

696+
697+
//Set final output dir
698+
if (config.hasOwnProperty("baseUrl")) {
699+
if (config.appDir) {
700+
config.dirBaseUrl = build.makeAbsPath(config.originalBaseUrl, config.dir);
701+
} else {
702+
config.dirBaseUrl = config.dir || config.baseUrl;
703+
}
704+
//Make sure dirBaseUrl ends in a slash, since it is
705+
//concatenated with other strings.
706+
config.dirBaseUrl = endsWithSlash(config.dirBaseUrl);
707+
}
708+
700709
//Check for errors in config
701710
if (config.cssIn && !config.out) {
702711
throw new Error("ERROR: 'out' option missing.");
@@ -714,10 +723,11 @@ function (lang, logger, file, parse, optimize, pragma,
714723
' or baseUrl directories optimized.');
715724
}
716725

717-
if (config.out && !config.cssIn) {
718-
//Just one file to optimize.
719-
720-
//Set up dummy module layer to build.
726+
if (config.name && !config.modules) {
727+
//Just need to build one file, but may be part of a whole appDir/
728+
//baseUrl copy, but specified on the command line, so cannot do
729+
//the modules array setup. So create a modules section in that
730+
//case.
721731
config.modules = [
722732
{
723733
name: config.name,
@@ -727,6 +737,10 @@ function (lang, logger, file, parse, optimize, pragma,
727737
excludeShallow: config.excludeShallow
728738
}
729739
];
740+
}
741+
742+
if (config.out && !config.cssIn) {
743+
//Just one file to optimize.
730744

731745
//Does not have a build file, so set up some defaults.
732746
//Optimizing CSS should not be allowed, unless explicitly

build/tests/builds.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,46 @@ define(['build', 'env!env/file'], function (build, file) {
127127
);
128128
doh.run();
129129

130+
doh.register("buildSimpleOverride",
131+
[
132+
function buildSimple(t) {
133+
//Do the build
134+
build(["simple.build.js", "dir=builds/simpleOverride"]);
135+
136+
t.is(nol(oneResult), nol(c("builds/simpleOverride/one.js")));
137+
138+
//Reset require internal state for the contexts so future
139+
//builds in these tests will work correctly.
140+
require._buildReset();
141+
}
142+
]
143+
);
144+
doh.run();
145+
146+
147+
doh.register("buildSimpleCommandLineName",
148+
[
149+
function buildSimpleCommandLineName(t) {
150+
//Do the build
151+
build([
152+
"baseUrl=../../../requirejs/tests",
153+
"optimize=none",
154+
"dir=builds/simpleCommandLineName",
155+
"name=one",
156+
"include=dimple"
157+
]);
158+
159+
t.is(nol(oneResult), nol(c("builds/simpleCommandLineName/one.js")));
160+
161+
//Reset require internal state for the contexts so future
162+
//builds in these tests will work correctly.
163+
require._buildReset();
164+
}
165+
]
166+
);
167+
doh.run();
168+
169+
130170
doh.register("buildExcludeShallow",
131171
[
132172
function buildExcludeShallow(t) {

build/tests/lib/moduleThenPlugin/expected.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require(['sub1'], function (sub1) {});
77
define("main", function(){});
88

99
/**
10-
* @license RequireJS text 1.0.2 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
10+
* @license RequireJS text 1.0.6 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
1111
* Available via the MIT or new BSD license.
1212
* see: http://github.com/jrburke/requirejs for details
1313
*/
@@ -49,7 +49,12 @@ define("main", function(){});
4949
fs = require.nodeRequire('fs');
5050

5151
get = function (url, callback) {
52-
callback(fs.readFileSync(url, 'utf8'));
52+
var file = fs.readFileSync(url, 'utf8')
53+
//Remove BOM (Byte Mark Order) from utf8 files if it is there.
54+
if (file.indexOf('\uFEFF') === 0) {
55+
file = file.substring(1);
56+
}
57+
callback(file);
5358
};
5459
} else if (typeof Packages !== 'undefined') {
5560
//Why Java, why is this so awkward?
@@ -92,7 +97,7 @@ define("main", function(){});
9297
}
9398

9499
text = {
95-
version: '1.0.2',
100+
version: '1.0.6',
96101

97102
strip: function (content) {
98103
//Strips <?xml ...?> declarations so that external SVG and XML

dist/r.js

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 1.0.5+ Wed, 01 Feb 2012 01:32:55 GMT Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
2+
* @license r.js 1.0.5+ Mon, 13 Feb 2012 05:57:30 GMT Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
2020

2121
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2222
nodeDefine, exists, reqMain, loadedOptimizedLib,
23-
version = '1.0.5+ Wed, 01 Feb 2012 01:32:55 GMT',
23+
version = '1.0.5+ Mon, 13 Feb 2012 05:57:30 GMT',
2424
jsSuffixRegExp = /\.js$/,
2525
commandOption = '',
2626
useLibLoaded = {},
@@ -102,7 +102,7 @@ var requirejs, require, define;
102102
}
103103

104104
/** vim: et:ts=4:sw=4:sts=4
105-
* @license RequireJS 1.0.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
105+
* @license RequireJS 1.0.5+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
106106
* Available via the MIT or new BSD license.
107107
* see: http://github.com/jrburke/requirejs for details
108108
*/
@@ -112,7 +112,7 @@ var requirejs, require, define;
112112

113113
(function () {
114114
//Change this version number for each release.
115-
var version = "1.0.5",
115+
var version = "1.0.5+",
116116
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
117117
cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
118118
currDirRegExp = /^\.\//,
@@ -1156,6 +1156,7 @@ var requirejs, require, define;
11561156
err = makeError("timeout", "Load timeout for modules: " + noLoads);
11571157
err.requireType = "timeout";
11581158
err.requireModules = noLoads;
1159+
err.contextName = context.contextName;
11591160
return req.onError(err);
11601161
}
11611162

@@ -8512,14 +8513,16 @@ define('commonJs', ['env!env/file', 'uglifyjs/index'], function (file, uglify) {
85128513
* see: http://github.com/jrburke/requirejs for details
85138514
*/
85148515

8515-
/*jslint regexp: false, plusplus: false, nomen: false, strict: false */
8516-
/*global define: false, require: false */
8516+
/*jslint plusplus: true, nomen: true */
8517+
/*global define, require */
85178518

85188519

85198520
define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma',
85208521
'env!env/load', 'requirePatch'],
85218522
function (lang, logger, file, parse, optimize, pragma,
85228523
load, requirePatch) {
8524+
'use strict';
8525+
85238526
var build, buildBaseConfig,
85248527
endsWithSemiColonRegExp = /;\s*$/;
85258528

@@ -9040,32 +9043,25 @@ function (lang, logger, file, parse, optimize, pragma,
90409043
* to the absFilePath passed in.
90419044
*/
90429045
build.makeAbsConfig = function (config, absFilePath) {
9043-
var props, prop, i, originalBaseUrl;
9046+
var props, prop, i;
90449047

90459048
props = ["appDir", "dir", "baseUrl"];
90469049
for (i = 0; (prop = props[i]); i++) {
90479050
if (config[prop]) {
90489051
//Add abspath if necessary, make sure these paths end in
90499052
//slashes
90509053
if (prop === "baseUrl") {
9051-
originalBaseUrl = config.baseUrl;
9054+
config.originalBaseUrl = config.baseUrl;
90529055
if (config.appDir) {
90539056
//If baseUrl with an appDir, the baseUrl is relative to
90549057
//the appDir, *not* the absFilePath. appDir and dir are
90559058
//made absolute before baseUrl, so this will work.
9056-
config.baseUrl = build.makeAbsPath(originalBaseUrl, config.appDir);
9057-
//Set up dir output baseUrl.
9058-
config.dirBaseUrl = build.makeAbsPath(originalBaseUrl, config.dir);
9059+
config.baseUrl = build.makeAbsPath(config.originalBaseUrl, config.appDir);
90599060
} else {
90609061
//The dir output baseUrl is same as regular baseUrl, both
90619062
//relative to the absFilePath.
90629063
config.baseUrl = build.makeAbsPath(config[prop], absFilePath);
9063-
config.dirBaseUrl = config.dir || config.baseUrl;
90649064
}
9065-
9066-
//Make sure dirBaseUrl ends in a slash, since it is
9067-
//concatenated with other strings.
9068-
config.dirBaseUrl = endsWithSlash(config.dirBaseUrl);
90699065
} else {
90709066
config[prop] = build.makeAbsPath(config[prop], absFilePath);
90719067
}
@@ -9138,12 +9134,13 @@ function (lang, logger, file, parse, optimize, pragma,
91389134
var config = {}, buildFileContents, buildFileConfig, mainConfig,
91399135
mainConfigFile, prop, buildFile, absFilePath;
91409136

9141-
lang.mixin(config, buildBaseConfig);
9142-
lang.mixin(config, cfg, true);
9143-
91449137
//Make sure all paths are relative to current directory.
91459138
absFilePath = file.absPath('.');
9146-
build.makeAbsConfig(config, absFilePath);
9139+
build.makeAbsConfig(cfg, absFilePath);
9140+
build.makeAbsConfig(buildBaseConfig, absFilePath);
9141+
9142+
lang.mixin(config, buildBaseConfig);
9143+
lang.mixin(config, cfg, true);
91479144

91489145
if (config.buildFile) {
91499146
//A build file exists, load it to get more config.
@@ -9205,6 +9202,19 @@ function (lang, logger, file, parse, optimize, pragma,
92059202
//args should take precedence over build file values.
92069203
mixConfig(config, cfg);
92079204

9205+
9206+
//Set final output dir
9207+
if (config.hasOwnProperty("baseUrl")) {
9208+
if (config.appDir) {
9209+
config.dirBaseUrl = build.makeAbsPath(config.originalBaseUrl, config.dir);
9210+
} else {
9211+
config.dirBaseUrl = config.dir || config.baseUrl;
9212+
}
9213+
//Make sure dirBaseUrl ends in a slash, since it is
9214+
//concatenated with other strings.
9215+
config.dirBaseUrl = endsWithSlash(config.dirBaseUrl);
9216+
}
9217+
92089218
//Check for errors in config
92099219
if (config.cssIn && !config.out) {
92109220
throw new Error("ERROR: 'out' option missing.");
@@ -9222,10 +9232,11 @@ function (lang, logger, file, parse, optimize, pragma,
92229232
' or baseUrl directories optimized.');
92239233
}
92249234

9225-
if (config.out && !config.cssIn) {
9226-
//Just one file to optimize.
9227-
9228-
//Set up dummy module layer to build.
9235+
if (config.name && !config.modules) {
9236+
//Just need to build one file, but may be part of a whole appDir/
9237+
//baseUrl copy, but specified on the command line, so cannot do
9238+
//the modules array setup. So create a modules section in that
9239+
//case.
92299240
config.modules = [
92309241
{
92319242
name: config.name,
@@ -9235,6 +9246,10 @@ function (lang, logger, file, parse, optimize, pragma,
92359246
excludeShallow: config.excludeShallow
92369247
}
92379248
];
9249+
}
9250+
9251+
if (config.out && !config.cssIn) {
9252+
//Just one file to optimize.
92389253

92399254
//Does not have a build file, so set up some defaults.
92409255
//Optimizing CSS should not be allowed, unless explicitly

require.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** vim: et:ts=4:sw=4:sts=4
2-
* @license RequireJS 1.0.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
2+
* @license RequireJS 1.0.5+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -9,7 +9,7 @@
99
var requirejs, require, define;
1010
(function () {
1111
//Change this version number for each release.
12-
var version = "1.0.5",
12+
var version = "1.0.5+",
1313
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
1414
cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
1515
currDirRegExp = /^\.\//,
@@ -1053,6 +1053,7 @@ var requirejs, require, define;
10531053
err = makeError("timeout", "Load timeout for modules: " + noLoads);
10541054
err.requireType = "timeout";
10551055
err.requireModules = noLoads;
1056+
err.contextName = context.contextName;
10561057
return req.onError(err);
10571058
}
10581059

0 commit comments

Comments
 (0)