Skip to content

Commit 13d87b4

Browse files
committed
snapshot
1 parent 938f9e8 commit 13d87b4

File tree

1 file changed

+81
-12
lines changed

1 file changed

+81
-12
lines changed

dist/r.js

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 2.1.1+ Sat, 17 Nov 2012 23:32:03 GMT Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
2+
* @license r.js 2.1.1+ Sun, 18 Nov 2012 19:55:34 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
*/
@@ -21,7 +21,7 @@ var requirejs, require, define;
2121

2222
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2323
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode,
24-
version = '2.1.1+ Sat, 17 Nov 2012 23:32:03 GMT',
24+
version = '2.1.1+ Sun, 18 Nov 2012 19:55:34 GMT',
2525
jsSuffixRegExp = /\.js$/,
2626
commandOption = '',
2727
useLibLoaded = {},
@@ -13523,7 +13523,7 @@ if(env === 'rhino') {
1352313523
/*jslint strict: false, plusplus: false */
1352413524
/*global define: false, java: false, Packages: false */
1352513525

13526-
define('rhino/optimize', ['logger'], function (logger) {
13526+
define('rhino/optimize', ['logger', 'env!env/file'], function (logger, file) {
1352713527

1352813528
//Add .reduce to Rhino so UglifyJS can run in Rhino,
1352913529
//inspired by https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce
@@ -13579,10 +13579,12 @@ define('rhino/optimize', ['logger'], function (logger) {
1357913579
jsSourceFile = closurefromCode(String(fileName), String(fileContents)),
1358013580
options, option, FLAG_compilation_level, compiler,
1358113581
Compiler = Packages.com.google.javascript.jscomp.Compiler,
13582-
result;
13582+
result, mappings, baseName;
1358313583

1358413584
logger.trace("Minifying file: " + fileName);
1358513585

13586+
baseName = (new java.io.File(fileName)).getName();
13587+
1358613588
//Set up options
1358713589
options = new jscomp.CompilerOptions();
1358813590
for (option in config.CompilerOptions) {
@@ -13597,15 +13599,25 @@ define('rhino/optimize', ['logger'], function (logger) {
1359713599
FLAG_compilation_level = jscomp.CompilationLevel[config.CompilationLevel || 'SIMPLE_OPTIMIZATIONS'];
1359813600
FLAG_compilation_level.setOptionsForCompilationLevel(options);
1359913601

13602+
if (config.generateSourceMaps) {
13603+
mappings = new java.util.ArrayList();
13604+
13605+
mappings.add(new com.google.javascript.jscomp.SourceMap.LocationMapping(fileName, baseName + ".src"));
13606+
options.setSourceMapLocationMappings(mappings);
13607+
options.setSourceMapOutputPath(fileName + ".map");
13608+
}
13609+
1360013610
//Trigger the compiler
1360113611
Compiler.setLoggingLevel(Packages.java.util.logging.Level[config.loggingLevel || 'WARNING']);
1360213612
compiler = new Compiler();
1360313613

1360413614
result = compiler.compile(externSourceFile, jsSourceFile, options);
13605-
if (!result.success) {
13606-
logger.error('Cannot closure compile file: ' + fileName + '. Skipping it.');
13615+
if (result.success) {
13616+
fileContents = String(compiler.toSource());
13617+
13618+
return config.generateSourceMaps ? {sourceMap: result.sourceMap, toSource: function() { return fileContents; }} : fileContents;
1360713619
} else {
13608-
fileContents = compiler.toSource();
13620+
logger.error('Cannot closure compile file: ' + fileName + '. Skipping it.');
1360913621
}
1361013622

1361113623
return fileContents;
@@ -13778,6 +13790,25 @@ function (lang, logger, envOptimize, file, parse,
1377813790
};
1377913791
}
1378013792

13793+
function getFileWriter(fileName, encoding) {
13794+
var outFile = new java.io.File(fileName), outWriter, parentDir;
13795+
13796+
parentDir = outFile.getAbsoluteFile().getParentFile();
13797+
if (!parentDir.exists()) {
13798+
if (!parentDir.mkdirs()) {
13799+
throw "Could not create directory: " + parentDir.getAbsolutePath();
13800+
}
13801+
}
13802+
13803+
if (encoding) {
13804+
outWriter = new java.io.OutputStreamWriter(new java.io.FileOutputStream(outFile), encoding);
13805+
} else {
13806+
outWriter = new java.io.OutputStreamWriter(new java.io.FileOutputStream(outFile));
13807+
}
13808+
13809+
return new java.io.BufferedWriter(outWriter);
13810+
}
13811+
1378113812
optimize = {
1378213813
/**
1378313814
* Optimizes a file that contains JavaScript content. Optionally collects
@@ -13794,13 +13825,29 @@ function (lang, logger, envOptimize, file, parse,
1379413825
* found.
1379513826
*/
1379613827
jsFile: function (fileName, fileContents, outFileName, config, pluginCollector) {
13828+
var optimized, compressed, baseName, writer;
13829+
1379713830
if (!fileContents) {
1379813831
fileContents = file.readFile(fileName);
1379913832
}
1380013833

13801-
fileContents = optimize.js(fileName, fileContents, config, pluginCollector);
13834+
optimized = optimize.js(fileName, fileContents, config, pluginCollector);
1380213835

13803-
file.saveUtf8File(outFileName, fileContents);
13836+
compressed = typeof optimized =='string' ? optimized : optimized.toSource();
13837+
13838+
if (config.generateSourceMaps && optimized.sourceMap) {
13839+
baseName = (new java.io.File(outFileName)).getName();
13840+
13841+
file.saveUtf8File(outFileName + ".src", fileContents);
13842+
13843+
writer = getFileWriter(outFileName + ".map", "utf-8");
13844+
optimized.sourceMap.appendTo(writer, outFileName);
13845+
writer.close();
13846+
13847+
compressed += "\n//@ sourceMappingURL=" + baseName + ".map";
13848+
}
13849+
13850+
file.saveUtf8File(outFileName, compressed);
1380413851
},
1380513852

1380613853
/**
@@ -13820,7 +13867,7 @@ function (lang, logger, envOptimize, file, parse,
1382013867
optimizerName = parts[0],
1382113868
keepLines = parts[1] === 'keepLines',
1382213869
licenseContents = '',
13823-
optFunc;
13870+
optFunc, optResult;
1382413871

1382513872
config = config || {};
1382613873

@@ -13845,8 +13892,13 @@ function (lang, logger, envOptimize, file, parse,
1384513892
}
1384613893
}
1384713894

13848-
fileContents = licenseContents + optFunc(fileName, fileContents, keepLines,
13849-
config[optimizerName]);
13895+
config[optimizerName] = config[optimizerName] || {};
13896+
13897+
config[optimizerName].generateSourceMaps = !!config.generateSourceMaps;
13898+
13899+
optResult = optFunc(fileName, fileContents, keepLines, config[optimizerName]);
13900+
13901+
return config.generateSourceMaps ? optResult : licenseContents + (typeof optResult == 'string' ? optResult : optResult.toSource());
1385013902
}
1385113903

1385213904
return fileContents;
@@ -15584,6 +15636,23 @@ define('build', function (require) {
1558415636
' to insert in to a require([]) call.');
1558515637
}
1558615638

15639+
if (config.generateSourceMaps) {
15640+
if (config.preserveLicenseComments) {
15641+
throw new Error('Cannot use preserveLicenseComments and ' +
15642+
'generateSourceMaps together. Either explcitly set ' +
15643+
'preserveLicenseComments to false (default is true) or ' +
15644+
'turn off generateSourceMaps. If you want source maps with ' +
15645+
'license comments, see: ' +
15646+
'http://requirejs.org/docs/errors.html#sourcemapcomments');
15647+
} else if (config.optimize !== 'none' && config.optimize !== 'closure') {
15648+
//Allow optimize: none to pass, since it is useful when toggling
15649+
//minification on and off to debug something, and it implicitly
15650+
//works, since it does not need a source map.
15651+
throw new Error('optimize: "' + config.optimize +
15652+
'" does not support generateSourceMaps.');
15653+
}
15654+
}
15655+
1558715656
if ((config.name || config.include) && !config.modules) {
1558815657
//Just need to build one file, but may be part of a whole appDir/
1558915658
//baseUrl copy, but specified on the command line, so cannot do

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy