mirror of
https://github.com/denoland/deno.git
synced 2024-12-11 18:17:48 -05:00
20 lines
513 B
TypeScript
20 lines
513 B
TypeScript
import Context from "./snapshot_preview1.ts";
|
|
|
|
const options = JSON.parse(Deno.args[0]);
|
|
const pathname = Deno.args[1];
|
|
const binary = await Deno.readFile(pathname);
|
|
const module = await WebAssembly.compile(binary);
|
|
|
|
const context = new Context({
|
|
env: options.env,
|
|
args: [pathname].concat(options.args),
|
|
preopens: options.preopens,
|
|
});
|
|
|
|
const instance = new WebAssembly.Instance(module, {
|
|
wasi_snapshot_preview1: context.exports,
|
|
});
|
|
|
|
context.memory = instance.exports.memory;
|
|
|
|
instance.exports._start();
|