diff options
author | 2023-06-01 21:16:47 -0400 | |
---|---|---|
committer | 2023-06-01 18:16:47 -0700 | |
commit | 4df1d37ddc54242c339765f22fb90ba2e9e3a99a (patch) | |
tree | d63ede76463e7ecba78a4d4b31e5e8158193552f /src/bun.js/wasi-runner.js | |
parent | 03ffd1c732aaaa30b5481f197221ce96da559e63 (diff) | |
download | bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.tar.gz bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.tar.zst bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.zip |
Bundle and minify `.exports.js` files. (#3036)
* move all exports.js into src/js
* finalize the sort of this
* and it works
* add test.ts to gitignore
* okay
* convert some to ts just to show
* finish up
* fixup makefile
* minify syntax in dev
* finish rebase
* dont minify all modules
* merge
* finish rebase merge
* flaky test that hangs
Diffstat (limited to 'src/bun.js/wasi-runner.js')
-rw-r--r-- | src/bun.js/wasi-runner.js | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/bun.js/wasi-runner.js b/src/bun.js/wasi-runner.js deleted file mode 100644 index 6a89510b1..000000000 --- a/src/bun.js/wasi-runner.js +++ /dev/null @@ -1,42 +0,0 @@ -/** --- WASI */ -// wasi is imported into the top of this file - -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 = "" } = 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 = Bun.fs(); - const file = import.meta.path; - source = fs.readFileSync(file); -} - -const wasm = new WebAssembly.Module(source); -const instance = !WASM_USE_ASYNC_INIT - ? new WebAssembly.Instance(wasm, wasi.getImports(wasm)) - : await WebAssembly.instantiate(wasm, wasi.getImports(wasm)); -wasi.start(instance); - -process.exit(0); |