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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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