MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / load

Function load

packages/plugins/apps/src/vite.ts:37–61  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

35 return id === virtualId ? resolvedVirtualId : null;
36 },
37 async load(id) {
38 if (id !== resolvedVirtualId) return null;
39 const artifact = await bundledWorkerBundler();
40 const paths = artifactPaths(artifact);
41 const output = [
42 `export const sourcePath = ${JSON.stringify(paths.sourcePath)};`,
43 `export const wasmPath = ${JSON.stringify(paths.wasmPath)};`,
44 ];
45
46 if (command === "serve") {
47 output.push(
48 `export const source = ${JSON.stringify(artifact.source)};`,
49 `export const wasmBase64 = ${JSON.stringify(Buffer.from(artifact.wasm).toString("base64"))};`,
50 "export default { sourcePath, wasmPath, source, wasmBase64 };",
51 );
52 } else {
53 output.push(
54 "export const source = undefined;",
55 "export const wasmBase64 = undefined;",
56 "export default { sourcePath, wasmPath, source, wasmBase64 };",
57 );
58 }
59
60 return output.join("\n");
61 },
62 async closeBundle() {
63 if (command !== "build") return;
64 const artifact = await bundledWorkerBundler();

Callers

nothing calls this directly

Calls 4

bundledWorkerBundlerFunction · 0.90
artifactPathsFunction · 0.85
pushMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected