diff --git a/docs/project/changelog.md b/docs/project/changelog.md index 0667de80b..d2f3df2a9 100644 --- a/docs/project/changelog.md +++ b/docs/project/changelog.md @@ -19,6 +19,12 @@ substitutions: error, it will return an empty list instead of raising a `SyntaxError`. {pr}`1819` +### Javascript package + +- {{Fix}} {any}`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 diff --git a/src/js/load-pyodide.js b/src/js/load-pyodide.js index 9f997c2fa..c7a38bb60 100644 --- a/src/js/load-pyodide.js +++ b/src/js/load-pyodide.js @@ -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);