Merge pull request #7569 from meteor/fix-misbehaving-promise-polyfill

Fix misbehaving promise polyfill.
This commit is contained in:
Ben Newman
2016-08-03 15:55:44 -04:00
committed by GitHub
2 changed files with 24 additions and 6 deletions

View File

@@ -1,10 +1,24 @@
// Install a global ES2015-compliant Promise constructor that knows how to
// run all its callbacks in Fibers.
var Promise = global.Promise = global.Promise ||
var Promise = global.Promise ||
require("promise/lib/es6-extensions");
require("meteor-promise").makeCompatible(
Promise,
require("fibers")
);
function makeCompatible(newPromise) {
require("meteor-promise").makeCompatible(
newPromise,
require("fibers")
);
}
makeCompatible(Promise);
Object.defineProperty(global, "Promise", {
get: function () {
return Promise;
},
// Make the new Promise compatible with Fibers, but do not allow further
// modifications to global.Promise, e.g. by misbehaving polyfills.
set: makeCompatible
});

View File

@@ -27,8 +27,10 @@ var release = require('../packaging/release.js');
var projectContextModule = require('../project-context.js');
var upgraders = require('../upgraders.js');
require("../tool-env/install-runtime.js");
try {
var phantomjs = require('phantomjs-prebuilt');
var phantomPath = require.resolve('phantomjs-prebuilt');
} catch (e) {
throw new Error([
"Please install PhantomJS by running the following command:",
@@ -40,6 +42,8 @@ try {
].join("\n"));
}
var phantomjs = require(phantomPath);
// To allow long stack traces that cross async boundaries
require('longjohn');