()
| 11 | |
| 12 | // arktype/runtime as a bundler resolves it for the browser, in one module |
| 13 | const 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 |
no test coverage detected