esbuild-wasm
browserからでも実行できる
もちろんpluginも使える
CDN経由ならjsdelivrが便利
Browserでの利用例
code:js
await (async () => {
const WASM_URL =
await initialize({
wasmURL: WASM_URL,
worker: false,
});
const result = await build({
stdin: {
contents: "console.log('hello, world');",
sourcefile: "test.ts",
resolveDir: "./",
},
bundle: true,
minify: true,
format: "esm",
write: false,
});
console.log(result.outputFiles0.text); })();
Denoでの使用例
code:mod.ts
export const WASM_URL =
code:test.ts
import { build, initialize, WASM_URL } from "./mod.ts";
code:test.ts
await initialize({
wasmURL: WASM_URL,
worker: false,
});
const result = await build({
stdin: {
contents: "console.log('hello, world');",
sourcefile: "test.ts",
resolveDir: Deno.cwd(),
},
bundle: true,
minify: true,
format: "esm",
write: false,
});
console.log(result.outputFiles0.text);