mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Update to use APIs from new versions of fibers and uglify-js.
Combine files before minimizing. minimongo - subkey sort fails when minized, so clearly there is some sort of uglify bug.
This commit is contained in:
@@ -378,36 +378,23 @@ _.extend(Bundle.prototype, {
|
||||
var self = this;
|
||||
|
||||
/// Javascript
|
||||
var code_parts = [];
|
||||
var codeParts = [];
|
||||
|
||||
_.each(self.js.client, function (js_path) {
|
||||
var code = self.files.client[js_path].toString('utf8');
|
||||
codeParts.push(self.files.client[js_path].toString('utf8'));
|
||||
|
||||
// Uglify has a bug -- it will incorrectly minifiy files that
|
||||
// contain the 'debugger' statement.
|
||||
// https://github.com/mishoo/UglifyJS/issues/243
|
||||
// For now, just skip minification of such files.
|
||||
// XXX fix uglify, and once that happens, go back to
|
||||
// concatenating before minifying, rather than vice versa
|
||||
// https://app.asana.com/0/159908330244/522242142181
|
||||
if (!(code.match(/debugger/))) {
|
||||
var ast = uglify.parser.parse(code);
|
||||
ast = uglify.uglify.ast_mangle(ast);
|
||||
ast = uglify.uglify.ast_squeeze(ast);
|
||||
code = uglify.uglify.gen_code(ast);
|
||||
}
|
||||
|
||||
code_parts.push(code);
|
||||
delete self.files.client[js_path];
|
||||
});
|
||||
var final_code = code_parts.join('\n;\n');
|
||||
var combinedCode = codeParts.join('\n;\n');
|
||||
var finalCode = uglify.minify(
|
||||
combinedCode, {fromString: true, compress: {drop_debugger: false}}).code;
|
||||
|
||||
var hash = crypto.createHash('sha1');
|
||||
hash.update(final_code);
|
||||
hash.update(finalCode);
|
||||
var digest = hash.digest('hex');
|
||||
var name = path.sep + digest + ".js";
|
||||
|
||||
self.files.client_cacheable[name] = new Buffer(final_code);
|
||||
self.files.client_cacheable[name] = new Buffer(finalCode);
|
||||
self.js.client = [name];
|
||||
|
||||
/// CSS
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
////////// Requires //////////
|
||||
|
||||
require("fibers");
|
||||
var Fiber = require("fibers");
|
||||
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
@@ -31,6 +31,8 @@ if (Meteor.isServer) {
|
||||
}
|
||||
});
|
||||
|
||||
var Fiber = __meteor_bootstrap__.require('fibers');
|
||||
|
||||
var sleep = function (ms) {
|
||||
var fiber = Fiber.current;
|
||||
setTimeout(function() {
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
return result;
|
||||
});
|
||||
|
||||
var Fiber = __meteor_bootstrap__.require('fibers');
|
||||
// Listen to incoming OAuth http requests
|
||||
__meteor_bootstrap__.app
|
||||
.use(connect.query())
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var Fiber = __meteor_bootstrap__.require('fibers');
|
||||
|
||||
/******************************************************************************/
|
||||
/* LivedataSession */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
(function () {
|
||||
|
||||
var Fiber = __meteor_bootstrap__.require('fibers');
|
||||
|
||||
var nextSlot = 0;
|
||||
|
||||
Meteor.EnvironmentVariable = function () {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var Fiber = __meteor_bootstrap__.require('fibers');
|
||||
|
||||
Tinytest.add("fibers - synchronous queue", function (test) {
|
||||
var q = new Meteor._SynchronousQueue;
|
||||
var output = [];
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
var path = __meteor_bootstrap__.require('path');
|
||||
var MongoDB = __meteor_bootstrap__.require('mongodb');
|
||||
var Fiber = __meteor_bootstrap__.require('fibers');
|
||||
var Future = __meteor_bootstrap__.require(path.join('fibers', 'future'));
|
||||
|
||||
_Mongo = function (url) {
|
||||
|
||||
@@ -108,6 +108,7 @@ Tinytest.addAsync("mongo-livedata - basics", function (test, onComplete) {
|
||||
|
||||
// sleep function from fibers docs.
|
||||
var sleep = function(ms) {
|
||||
var Fiber = __meteor_bootstrap__.require('fibers');
|
||||
var fiber = Fiber.current;
|
||||
setTimeout(function() {
|
||||
fiber.run();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
(function () {
|
||||
var Fiber = __meteor_bootstrap__.require('fibers');
|
||||
var handlesForRun = {};
|
||||
var reportsForRun = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user