Improved Promise polyfill for MicroPython only (#1517)

This commit is contained in:
Andrea Giammarchi
2023-06-09 12:53:31 +02:00
committed by GitHub
parent 50b1a1d7c5
commit 818614b798
4 changed files with 10 additions and 44 deletions

View File

@@ -10,12 +10,19 @@ import {
const type = "micropython";
let patchPromise = true;
// REQUIRES INTEGRATION TEST
/* c8 ignore start */
export default {
type: [type, "mpy"],
module: () => `http://localhost:8080/micropython/micropython.mjs`,
async engine({ loadMicroPython }, config, url) {
// @bug https://github.com/micropython/micropython/issues/11749
if (patchPromise) {
patchPromise = false;
globalThis.Promise = class extends Promise {};
}
const { stderr, stdout, get } = stdio();
url = url.replace(/\.m?js$/, ".wasm");
const runtime = await get(loadMicroPython({ stderr, stdout, url }));