use our fork of es6-promise with flush exposed as the promise polyfill

This commit is contained in:
Bruno Windels 2020-09-28 15:27:38 +02:00
parent 8366b44d8c
commit e3581c8260
5 changed files with 20 additions and 1 deletions

View file

@ -47,6 +47,7 @@
"xxhashjs": "^0.2.2"
},
"dependencies": {
"es6-promise": "https://github.com/bwindels/es6-promise.git#bwindels/expose-flush",
"aes-js": "^3.1.2",
"another-json": "^0.2.0",
"base64-arraybuffer": "^0.2.0",

View file

@ -96,6 +96,15 @@ async function populateLib() {
path.join(modulesDir, 'aes-js/index.js'),
path.join(libDir, "aes-js/index.js")
);
// es6-promise is already written as an es module,
// but it does need to be babelified, and current we don't babelify
// anything in node_modules in the build script, so make a bundle that
// is conveniently not placed in node_modules rather than symlinking.
await fs.mkdir(path.join(libDir, "es6-promise/"));
await commonjsToESM(
path.join(modulesDir, 'es6-promise/lib/es6-promise/promise.js'),
path.join(libDir, "es6-promise/index.js")
);
}
populateLib();

View file

@ -26,8 +26,8 @@ import "mdn-polyfills/Element.prototype.closest";
// it will also include the file supporting *all* the encodings,
// weighing a good extra 500kb :-(
import "text-encoding";
import Promise from "../lib/es6-promise/lib/es6-promise/promise.js";
import {checkNeedsSyncPromise} from "./matrix/storage/idb/utils.js";
import Promise from "../lib/es6-promise/index.js";
const flush = Promise._flush;
Promise._flush = function() {

View file

@ -48,3 +48,8 @@ import "core-js/modules/es.typed-array.to-locale-string";
import "core-js/modules/es.typed-array.to-string";
import "core-js/modules/es.typed-array.iterator";
import "core-js/modules/es.object.to-string";
import Promise from "../lib/es6-promise/index.js";
// not calling checkNeedsSyncPromise from here as we don't do any idb in the worker,
// mainly because IE doesn't handle multiple concurrent connections well
self.Promise = Promise;

View file

@ -1205,6 +1205,10 @@ entities@^2.0.0:
resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.0.tgz#68d6084cab1b079767540d80e56a39b423e4abf4"
integrity sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw==
"es6-promise@https://github.com/bwindels/es6-promise.git#bwindels/expose-flush":
version "4.2.8"
resolved "https://github.com/bwindels/es6-promise.git#112f78f5829e627055b0ff56a52fecb63f6003b1"
escalade@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.0.2.tgz#6a580d70edb87880f22b4c91d0d56078df6962c4"