fix(Code Node): Use an explicit indexURL to load the pyodide runtime (#14487)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2025-04-09 10:20:14 +02:00
committed by GitHub
parent 9ba58ca80b
commit 860bb1ef92

View File

@@ -1,3 +1,4 @@
import { dirname } from 'node:path';
import type { PyodideInterface } from 'pyodide'; import type { PyodideInterface } from 'pyodide';
let pyodideInstance: PyodideInterface | undefined; let pyodideInstance: PyodideInterface | undefined;
@@ -5,7 +6,8 @@ let pyodideInstance: PyodideInterface | undefined;
export async function LoadPyodide(packageCacheDir: string): Promise<PyodideInterface> { export async function LoadPyodide(packageCacheDir: string): Promise<PyodideInterface> {
if (pyodideInstance === undefined) { if (pyodideInstance === undefined) {
const { loadPyodide } = await import('pyodide'); const { loadPyodide } = await import('pyodide');
pyodideInstance = await loadPyodide({ packageCacheDir }); const indexURL = dirname(require.resolve('pyodide'));
pyodideInstance = await loadPyodide({ indexURL, packageCacheDir });
await pyodideInstance.runPythonAsync(` await pyodideInstance.runPythonAsync(`
from _pyodide_core import jsproxy_typedict from _pyodide_core import jsproxy_typedict