MCPcopy
hub / github.com/pyodide/pyodide / nodeLoadScript

Function nodeLoadScript

src/js/compat.ts:228–243  ·  view source on GitHub ↗

* Load the pyodide.asm.mjs ES6 module in Node.js. * @param url The path to load. May be a url or a relative file system path. * @private

(url: string)

Source from the content-addressed store, hash-verified

226 * @private
227 */
228async function nodeLoadScript(url: string) {
229 if (url.startsWith("file://")) {
230 // handle file:// with filesystem operations rather than with fetch.
231 url = url.slice("file://".length);
232 }
233 if (url.includes("://")) {
234 // If it's a url, use dynamic import.
235 return await import(/* webpackIgnore: true */ url);
236 } else {
237 // Otherwise, hopefully it is a relative path we can load from the file
238 // system.
239 return await import(
240 /* webpackIgnore: true */ nodeUrlMod.pathToFileURL(url).href
241 );
242 }
243}
244
245export async function loadLockFile(lockFileURL: string): Promise<Lockfile> {
246 if (RUNTIME_ENV.IN_NODE) {

Callers

nothing calls this directly

Calls 2

sliceMethod · 0.80
includesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…