mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-22 03:35:31 -05:00
Use registerJSModule when available (#1573)
This commit is contained in:
committed by
GitHub
parent
7813c3f03f
commit
a14e701be4
@@ -1,7 +1,7 @@
|
||||
import "@ungap/with-resolvers";
|
||||
|
||||
import { getBuffer } from "../fetch-utils.js";
|
||||
import { absoluteURL } from "../utils.js";
|
||||
import { absoluteURL, entries } from "../utils.js";
|
||||
|
||||
/**
|
||||
* Trim code only if it's a single line that prettier or other tools might have modified.
|
||||
@@ -131,3 +131,12 @@ export const fetchPaths = (module, interpreter, config_fetch) =>
|
||||
.then((buffer) => module.writeFile(interpreter, path, buffer)),
|
||||
),
|
||||
);
|
||||
|
||||
// this is a fallback for interpreters unable to register JS modules
|
||||
// all defined keys will end up as globally available references
|
||||
// REQUIRES INTEGRATION TEST
|
||||
/* c8 ignore start */
|
||||
export function registerJSModule(interpreter, _, value) {
|
||||
for (const [k, v] of entries(value)) this.setGlobal(interpreter, k, v);
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
|
||||
Reference in New Issue
Block a user