1
1
/**
2
- * @license r.js 2.1.22+ Tue, 15 Mar 2016 21:57:59 GMT Copyright jQuery Foundation and other contributors.
2
+ * @license r.js 2.1.22+ Tue, 15 Mar 2016 23:27:47 GMT Copyright jQuery Foundation and other contributors.
3
3
* Released under MIT license, http://github.com/requirejs/r.js/LICENSE
4
4
*/
5
5
@@ -19,7 +19,7 @@ var requirejs, require, define, xpcUtil;
19
19
(function (console, args, readFileFunc) {
20
20
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
21
21
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
22
- version = '2.1.22+ Tue, 15 Mar 2016 21:57:59 GMT',
22
+ version = '2.1.22+ Tue, 15 Mar 2016 23:27:47 GMT',
23
23
jsSuffixRegExp = /\.js$/,
24
24
commandOption = '',
25
25
useLibLoaded = {},
@@ -24918,6 +24918,8 @@ define('build', function (require) {
24918
24918
findNestedDependencies: false,
24919
24919
preserveLicenseComments: true,
24920
24920
writeBuildTxt: true,
24921
+ //Some builds can take a while, up the default limit.
24922
+ waitSeconds: 30,
24921
24923
//By default, all files/directories are copied, unless
24922
24924
//they match this regexp, by default just excludes .folders
24923
24925
dirExclusionRegExp: file.dirExclusionRegExp,
@@ -24945,6 +24947,13 @@ define('build', function (require) {
24945
24947
return dirName;
24946
24948
}
24947
24949
24950
+ function endsWithNewLine(text) {
24951
+ if (text.charAt(text.length - 1) !== "\n") {
24952
+ text += "\n";
24953
+ }
24954
+ return text;
24955
+ }
24956
+
24948
24957
//Method used by plugin writeFile calls, defined up here to avoid
24949
24958
//jslint warning about "making a function in a loop".
24950
24959
function makeWriteFile(namespace, layer) {
@@ -24961,6 +24970,75 @@ define('build', function (require) {
24961
24970
return writeFile;
24962
24971
}
24963
24972
24973
+ /**
24974
+ * Appends singleContents to fileContents and returns the result. If a sourceMapGenerator
24975
+ * is provided, adds singleContents to the source map.
24976
+ *
24977
+ * @param {string} fileContents - The file contents to which to append singleContents
24978
+ * @param {string} singleContents - The additional contents to append to fileContents
24979
+ * @param {string} path - An absolute path of a file whose name to use in the source map.
24980
+ * The file need not actually exist if the code in singleContents is generated.
24981
+ * @param {{out: ?string, baseUrl: ?string}} config - The build configuration object.
24982
+ * @param {?{_buildPath: ?string}} module - An object with module information.
24983
+ * @param {?SourceMapGenerator} sourceMapGenerator - An instance of Mozilla's SourceMapGenerator,
24984
+ * or null if no source map is being generated.
24985
+ * @returns {string} fileContents with singleContents appended
24986
+ */
24987
+ function appendToFileContents(fileContents, singleContents, path, config, module, sourceMapGenerator) {
24988
+ var refPath, sourceMapPath, resourcePath, pluginId, sourceMapLineNumber, lineCount, parts, i;
24989
+ if (sourceMapGenerator) {
24990
+ if (config.out) {
24991
+ refPath = config.baseUrl;
24992
+ } else if (module && module._buildPath) {
24993
+ refPath = module._buildPath;
24994
+ } else {
24995
+ refPath = "";
24996
+ }
24997
+ parts = path.split('!');
24998
+ if (parts.length === 1) {
24999
+ //Not a plugin resource, fix the path
25000
+ sourceMapPath = build.makeRelativeFilePath(refPath, path);
25001
+ } else {
25002
+ //Plugin resource. If it looks like just a plugin
25003
+ //followed by a module ID, pull off the plugin
25004
+ //and put it at the end of the name, otherwise
25005
+ //just leave it alone.
25006
+ pluginId = parts.shift();
25007
+ resourcePath = parts.join('!');
25008
+ if (resourceIsModuleIdRegExp.test(resourcePath)) {
25009
+ sourceMapPath = build.makeRelativeFilePath(refPath, require.toUrl(resourcePath)) +
25010
+ '!' + pluginId;
25011
+ } else {
25012
+ sourceMapPath = path;
25013
+ }
25014
+ }
25015
+
25016
+ sourceMapLineNumber = fileContents.split('\n').length - 1;
25017
+ lineCount = singleContents.split('\n').length;
25018
+ for (i = 1; i <= lineCount; i += 1) {
25019
+ sourceMapGenerator.addMapping({
25020
+ generated: {
25021
+ line: sourceMapLineNumber + i,
25022
+ column: 0
25023
+ },
25024
+ original: {
25025
+ line: i,
25026
+ column: 0
25027
+ },
25028
+ source: sourceMapPath
25029
+ });
25030
+ }
25031
+
25032
+ //Store the content of the original in the source
25033
+ //map since other transforms later like minification
25034
+ //can mess up translating back to the original
25035
+ //source.
25036
+ sourceMapGenerator.setSourceContent(sourceMapPath, singleContents);
25037
+ }
25038
+ fileContents += singleContents;
25039
+ return fileContents;
25040
+ }
25041
+
24964
25042
/**
24965
25043
* Main API entry point into the build. The args argument can either be
24966
25044
* an array of arguments (like the onese passed on a command-line),
@@ -25621,7 +25699,9 @@ define('build', function (require) {
25621
25699
"insertRequire": true,
25622
25700
"stubModules": true,
25623
25701
"deps": true,
25624
- "mainConfigFile": true
25702
+ "mainConfigFile": true,
25703
+ "wrap.startFile": true,
25704
+ "wrap.endFile": true
25625
25705
};
25626
25706
25627
25707
for (i = 0; i < ary.length; i++) {
@@ -25831,22 +25911,37 @@ define('build', function (require) {
25831
25911
* Converts a wrap.startFile or endFile to be start/end as a string.
25832
25912
* the startFile/endFile values can be arrays.
25833
25913
*/
25834
- function flattenWrapFile(wrap, keyName, absFilePath) {
25835
- var keyFileName = keyName + 'File';
25914
+ function flattenWrapFile(config, keyName, absFilePath) {
25915
+ var wrap = config.wrap,
25916
+ keyFileName = keyName + 'File',
25917
+ keyMapName = '__' + keyName + 'Map';
25836
25918
25837
25919
if (typeof wrap[keyName] !== 'string' && wrap[keyFileName]) {
25838
25920
wrap[keyName] = '';
25839
25921
if (typeof wrap[keyFileName] === 'string') {
25840
25922
wrap[keyFileName] = [wrap[keyFileName]];
25841
25923
}
25924
+ wrap[keyMapName] = [];
25842
25925
wrap[keyFileName].forEach(function (fileName) {
25843
- wrap[keyName] += (wrap[keyName] ? '\n' : '') +
25844
- file.readFile(build.makeAbsPath(fileName, absFilePath));
25926
+ var absPath = build.makeAbsPath(fileName, absFilePath),
25927
+ fileText = endsWithNewLine(file.readFile(absPath));
25928
+ wrap[keyMapName].push(function (fileContents, cfg, sourceMapGenerator) {
25929
+ return appendToFileContents(fileContents, fileText, absPath, cfg, null, sourceMapGenerator);
25930
+ });
25931
+ wrap[keyName] += fileText;
25845
25932
});
25846
25933
} else if (wrap[keyName] === null || wrap[keyName] === undefined) {
25847
25934
//Allow missing one, just set to empty string.
25848
25935
wrap[keyName] = '';
25849
- } else if (typeof wrap[keyName] !== 'string') {
25936
+ } else if (typeof wrap[keyName] === 'string') {
25937
+ wrap[keyName] = endsWithNewLine(wrap[keyName]);
25938
+ wrap[keyMapName] = [
25939
+ function (fileContents, cfg, sourceMapGenerator) {
25940
+ var absPath = build.makeAbsPath("config-wrap-" + keyName + "-default.js", absFilePath);
25941
+ return appendToFileContents(fileContents, wrap[keyName], absPath, cfg, null, sourceMapGenerator);
25942
+ }
25943
+ ];
25944
+ } else {
25850
25945
throw new Error('wrap.' + keyName + ' or wrap.' + keyFileName + ' malformed');
25851
25946
}
25852
25947
}
@@ -25858,12 +25953,27 @@ define('build', function (require) {
25858
25953
if (config.wrap === true) {
25859
25954
//Use default values.
25860
25955
config.wrap = {
25861
- start: '(function () {',
25862
- end: '}());'
25956
+ start: '(function () {\n',
25957
+ end: '}());',
25958
+ __startMap: [
25959
+ function (fileContents, cfg, sourceMapGenerator) {
25960
+ return appendToFileContents(fileContents, "(function () {\n",
25961
+ build.makeAbsPath("config-wrap-start-default.js",
25962
+ absFilePath), cfg, null,
25963
+ sourceMapGenerator);
25964
+ }
25965
+ ],
25966
+ __endMap: [
25967
+ function (fileContents, cfg, sourceMapGenerator) {
25968
+ return appendToFileContents(fileContents, "}());",
25969
+ build.makeAbsPath("config-wrap-end-default.js", absFilePath),
25970
+ cfg, null, sourceMapGenerator);
25971
+ }
25972
+ ]
25863
25973
};
25864
25974
} else {
25865
- flattenWrapFile(config.wrap , 'start', absFilePath);
25866
- flattenWrapFile(config.wrap , 'end', absFilePath);
25975
+ flattenWrapFile(config, 'start', absFilePath);
25976
+ flattenWrapFile(config, 'end', absFilePath);
25867
25977
}
25868
25978
}
25869
25979
} catch (wrapError) {
@@ -26623,11 +26733,16 @@ define('build', function (require) {
26623
26733
});
26624
26734
26625
26735
//Write the built module to disk, and build up the build output.
26626
- fileContents = config.wrap ? config.wrap.start : "";
26736
+ fileContents = "";
26737
+ if (config.wrap && config.wrap.__startMap) {
26738
+ config.wrap.__startMap.forEach(function (wrapFunction) {
26739
+ fileContents = wrapFunction(fileContents, config, sourceMapGenerator);
26740
+ });
26741
+ }
26742
+
26627
26743
return prim.serial(layer.buildFilePaths.map(function (path) {
26628
26744
return function () {
26629
- var lineCount,
26630
- singleContents = '';
26745
+ var singleContents = '';
26631
26746
26632
26747
moduleName = layer.buildFileToModule[path];
26633
26748
@@ -26724,9 +26839,7 @@ define('build', function (require) {
26724
26839
});
26725
26840
}
26726
26841
}).then(function () {
26727
- var refPath, pluginId, resourcePath, shimDeps,
26728
- sourceMapPath, sourceMapLineNumber,
26729
- shortPath = path.replace(config.dir, "");
26842
+ var shimDeps, shortPath = path.replace(config.dir, "");
26730
26843
26731
26844
module.onCompleteData.included.push(shortPath);
26732
26845
buildFileContents += shortPath + "\n";
@@ -26773,66 +26886,24 @@ define('build', function (require) {
26773
26886
//for concatenation would cause an error otherwise.
26774
26887
singleContents += '\n';
26775
26888
26776
- //Add to the source map
26777
- if (sourceMapGenerator) {
26778
- refPath = config.out ? config.baseUrl : module._buildPath;
26779
- parts = path.split('!');
26780
- if (parts.length === 1) {
26781
- //Not a plugin resource, fix the path
26782
- sourceMapPath = build.makeRelativeFilePath(refPath, path);
26783
- } else {
26784
- //Plugin resource. If it looks like just a plugin
26785
- //followed by a module ID, pull off the plugin
26786
- //and put it at the end of the name, otherwise
26787
- //just leave it alone.
26788
- pluginId = parts.shift();
26789
- resourcePath = parts.join('!');
26790
- if (resourceIsModuleIdRegExp.test(resourcePath)) {
26791
- sourceMapPath = build.makeRelativeFilePath(refPath, require.toUrl(resourcePath)) +
26792
- '!' + pluginId;
26793
- } else {
26794
- sourceMapPath = path;
26795
- }
26796
- }
26797
-
26798
- sourceMapLineNumber = fileContents.split('\n').length - 1;
26799
- lineCount = singleContents.split('\n').length;
26800
- for (var i = 1; i <= lineCount; i += 1) {
26801
- sourceMapGenerator.addMapping({
26802
- generated: {
26803
- line: sourceMapLineNumber + i,
26804
- column: 0
26805
- },
26806
- original: {
26807
- line: i,
26808
- column: 0
26809
- },
26810
- source: sourceMapPath
26811
- });
26812
- }
26813
-
26814
- //Store the content of the original in the source
26815
- //map since other transforms later like minification
26816
- //can mess up translating back to the original
26817
- //source.
26818
- sourceMapGenerator.setSourceContent(sourceMapPath, singleContents);
26819
- }
26820
-
26821
- //Add the file to the final contents
26822
- fileContents += singleContents;
26889
+ //Add to the source map and to the final contents
26890
+ fileContents = appendToFileContents(fileContents, singleContents, path, config, module,
26891
+ sourceMapGenerator);
26823
26892
});
26824
26893
};
26825
26894
})).then(function () {
26826
26895
if (onLayerEnds.length) {
26827
- onLayerEnds.forEach(function (builder) {
26896
+ onLayerEnds.forEach(function (builder, index ) {
26828
26897
var path;
26829
26898
if (typeof module.out === 'string') {
26830
26899
path = module.out;
26831
26900
} else if (typeof module._buildPath === 'string') {
26832
26901
path = module._buildPath;
26833
26902
}
26834
26903
builder.onLayerEnd(function (input) {
26835
- fileContents += "\n" + addSemiColon(input, config);
26904
+ fileContents =
26905
+ appendToFileContents(fileContents, "\n" + addSemiColon(input, config),
26906
+ 'onLayerEnd' + index + '.js', config, module, sourceMapGenerator);
26836
26907
}, {
26837
26908
name: module.name,
26838
26909
path: path
@@ -26845,21 +26916,30 @@ define('build', function (require) {
26845
26916
//a module definition for it in case the
26846
26917
//built file is used with enforceDefine
26847
26918
//(#432)
26848
- fileContents += '\n' + namespaceWithDot + 'define("' + module.name + '", function(){});\n';
26919
+ fileContents =
26920
+ appendToFileContents(fileContents, '\n' + namespaceWithDot + 'define("' + module.name +
26921
+ '", function(){});\n', 'module-create.js', config, module,
26922
+ sourceMapGenerator);
26849
26923
}
26850
26924
26851
26925
//Add a require at the end to kick start module execution, if that
26852
26926
//was desired. Usually this is only specified when using small shim
26853
26927
//loaders like almond.
26854
26928
if (module.insertRequire) {
26855
- fileContents += '\n' + namespaceWithDot + 'require(["' + module.insertRequire.join('", "') + '"]);\n';
26929
+ fileContents =
26930
+ appendToFileContents(fileContents, '\n' + namespaceWithDot + 'require(["' + module.insertRequire.join('", "') +
26931
+ '"]);\n', 'module-insertRequire.js', config, module,
26932
+ sourceMapGenerator);
26856
26933
}
26857
26934
});
26858
26935
}).then(function () {
26936
+ if (config.wrap && config.wrap.__endMap) {
26937
+ config.wrap.__endMap.forEach(function (wrapFunction) {
26938
+ fileContents = wrapFunction(fileContents, config, sourceMapGenerator);
26939
+ });
26940
+ }
26859
26941
return {
26860
- text: config.wrap ?
26861
- fileContents + config.wrap.end :
26862
- fileContents,
26942
+ text: fileContents,
26863
26943
buildText: buildFileContents,
26864
26944
sourceMap: sourceMapGenerator ?
26865
26945
JSON.stringify(sourceMapGenerator.toJSON(), null, ' ') :
0 commit comments