/** This file is used when a .wasm file is ran. * The transpiled contents of `./node/wasi.js` is pasted into the top of this file. */ import { WASI } from "node:wasi"; const filePath = process.argv.at(1); if (!filePath) { var err = new Error("To run a wasm file with Bun, the first argument must be a path to a .wasm file"); err.name = "WasmFileNotFound"; throw err; } // The module specifier is the resolved path to the wasm file var { WASM_CWD = process.cwd(), WASM_ROOT_DIR = "/", WASM_ENV_STR = undefined, WASM_USE_ASYNC_INIT = "1", } = process.env; var env = process.env; if (WASM_ENV_STR?.length) { env = JSON.parse(WASM_ENV_STR); } const wasi = new WASI({ args: process.argv.slice(1), env, preopens: { ".": WASM_CWD || process.cwd(), "/": WASM_ROOT_DIR || "/", }, }); let source = globalThis.wasmSourceBytes; if (!source) { const fs = import.meta.require("fs"); const file = import.meta.path; source = fs.readFileSync(file); } const wasm = await WebAssembly.compile(source); const instance = !Number(WASM_USE_ASYNC_INIT) ? new WebAssembly.Instance(wasm, wasi.getImports(wasm)) : await WebAssembly.instantiate(wasm, wasi.getImports(wasm)); wasi.start(instance); process.reallyExit(0); ore Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/packages/renderers (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-07-11Filter out astro from `peerDependencies` in `astro add` (#7620)Gravatar Chris Swithinbank 2-1/+7
2023-07-11[ci] formatGravatar bluwy 1-1/+1
2023-07-11Refactor simple CLI commands (#7619)Gravatar Bjorn Lu 12-115/+123
2023-07-10fix: `astro info` command fallback for package manager (#7618)Gravatar Emanuele Stoppa 2-1/+7
2023-07-10Add CLI startup speed benchmark (#7617)Gravatar Bjorn Lu 5-11/+95
2023-07-10[ci] formatGravatar bluwy 1-1/+1