MCPcopy Create free account
hub / github.com/arktypeio/arktype / bundleRuntime

Function bundleRuntime

ark/docs/lib/writePrecompileWorker.ts:13–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12// arktype/runtime as a bundler resolves it for the browser, in one module
13const bundleRuntime = (): Pick<
14 PrecompileRuntime,
15 "code" | "localsByExport"
16> => {
17 const [{ text }] = buildSync({
18 stdin: {
19 contents: `export * from "arktype/runtime"`,
20 resolveDir: docsDir
21 },
22 bundle: true,
23 format: "esm",
24 platform: "browser",
25 write: false,
26 logLevel: "warning"
27 }).outputFiles
28 const exported = exportsPattern.exec(text)
29 if (!exported) throw new Error("arktype/runtime bundled without exports")
30 const localsByExport: Record<string, string> = {}
31 for (const specifier of exported[1].split(",")) {
32 const [local, name = local] = specifier.trim().split(/\s+as\s+/)
33 if (local) localsByExport[name] = local
34 }
35 return { code: text.replace(exportsPattern, ""), localsByExport }
36}
37
38/**
39 * Bundles the playground's Precompiled tab's measuring worker, with the

Callers 1

writePrecompileWorkerFunction · 0.85

Calls 2

execMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected