mirror of https://github.com/pyodide/pyodide.git
Fix `IN_NODE`: avoid error with unrelated global. (#1849)
This commit is contained in:
parent
f03db870a2
commit
d7106294ce
|
@ -19,6 +19,12 @@ substitutions:
|
|||
error, it will return an empty list instead of raising a `SyntaxError`.
|
||||
{pr}`1819`
|
||||
|
||||
### Javascript package
|
||||
|
||||
- {{Fix}} {any}`loadPyodide <globalThis.loadPyodide>` no longer fails in the
|
||||
presence of a user-defined global named `process`.
|
||||
{pr}`1849`
|
||||
|
||||
### Python / JavaScript type conversions
|
||||
|
||||
- {{Enhancement}} Updated the calling convention when a Javascript function is
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { Module } from "./module.js";
|
||||
|
||||
const IN_NODE =
|
||||
typeof process !== "undefined" && process.release.name !== "undefined";
|
||||
typeof process !== "undefined" &&
|
||||
process.release &&
|
||||
process.release.name === "node";
|
||||
|
||||
/** @typedef {import('./pyproxy.js').PyProxy} PyProxy */
|
||||
/** @private */
|
||||
|
@ -68,7 +70,7 @@ if (globalThis.document) {
|
|||
// This is async only for consistency
|
||||
globalThis.importScripts(url);
|
||||
};
|
||||
} else if (typeof process !== "undefined" && process.release.name === "node") {
|
||||
} else if (IN_NODE) {
|
||||
const pathPromise = import("path").then((M) => M.default);
|
||||
const fetchPromise = import("node-fetch").then((M) => M.default);
|
||||
const vmPromise = import("vm").then((M) => M.default);
|
||||
|
|
Loading…
Reference in New Issue