diff --git a/plugos/syscalls/esbuild.ts b/plugos/syscalls/esbuild.ts index ddb49ce8..045f5a5e 100644 --- a/plugos/syscalls/esbuild.ts +++ b/plugos/syscalls/esbuild.ts @@ -2,6 +2,9 @@ import { sandboxCompile, sandboxCompileModule } from "../compile.ts"; import { SysCallMapping } from "../system.ts"; import { Manifest } from "../types.ts"; +import importMap from "../../import_map.json" assert { type: "json" }; +import { base64EncodedDataUrl } from "../asset_bundle/base64.ts"; + export function esbuildSyscalls( imports: Manifest[], ): SysCallMapping { @@ -12,6 +15,14 @@ export function esbuildSyscalls( code: string, functionName?: string, ): Promise => { + // Override this to point to a URL + importMap.imports["$sb/"] = "https://deno.land/x/silverbullet/plug-api/"; + const importUrl = new URL( + base64EncodedDataUrl( + "application/json", + new TextEncoder().encode(JSON.stringify(importMap)), + ), + ); return await sandboxCompile( filename, code, @@ -19,6 +30,7 @@ export function esbuildSyscalls( { debug: true, imports, + importMap: importUrl, }, ); }, diff --git a/scripts/build_website.sh b/scripts/build_website.sh index 86f784fd..4a94737e 100755 --- a/scripts/build_website.sh +++ b/scripts/build_website.sh @@ -8,5 +8,6 @@ curl -fsSL https://deno.land/install.sh | sh export PATH=~/.deno/bin:$PATH deno task build deno task bundle -mkdir website_build/silverbullet.js -cp dist/silverbullet.js website_build/silverbullet.js/ \ No newline at end of file +mkdir website_build/silverbullet +cp dist/silverbullet.js website_build/silverbullet/ +cp dist_bundle/web/global.plug.json website_build/silverbullet/ \ No newline at end of file