Website build

pull/109/head
Zef Hemel 2022-10-29 11:41:11 +02:00
parent 08f653a481
commit 4c79fb155f
2 changed files with 15 additions and 2 deletions

View File

@ -2,6 +2,9 @@ import { sandboxCompile, sandboxCompileModule } from "../compile.ts";
import { SysCallMapping } from "../system.ts"; import { SysCallMapping } from "../system.ts";
import { Manifest } from "../types.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( export function esbuildSyscalls(
imports: Manifest<any>[], imports: Manifest<any>[],
): SysCallMapping { ): SysCallMapping {
@ -12,6 +15,14 @@ export function esbuildSyscalls(
code: string, code: string,
functionName?: string, functionName?: string,
): Promise<string> => { ): Promise<string> => {
// 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( return await sandboxCompile(
filename, filename,
code, code,
@ -19,6 +30,7 @@ export function esbuildSyscalls(
{ {
debug: true, debug: true,
imports, imports,
importMap: importUrl,
}, },
); );
}, },

View File

@ -8,5 +8,6 @@ curl -fsSL https://deno.land/install.sh | sh
export PATH=~/.deno/bin:$PATH export PATH=~/.deno/bin:$PATH
deno task build deno task build
deno task bundle deno task bundle
mkdir website_build/silverbullet.js mkdir website_build/silverbullet
cp dist/silverbullet.js website_build/silverbullet.js/ cp dist/silverbullet.js website_build/silverbullet/
cp dist_bundle/web/global.plug.json website_build/silverbullet/