[Feature request] Inlining wasm binary
Opened this issue · 2 comments
riywo commented
For some Node.js runtime environment such as AWS Lambda, it would be nice to have a pure JS implementation without extra file access like a wasm file because some bundling process doesn't recognize such extra files automatically.
Could you provide another package like re2-wasm-inline
by inlining the wasm binary as a Buffer
so that the extra wasm file isn't required?
Or, if your licensing term allows, I can also create such a package and publish it to npmjs on behalf.
Let me know your opinion!
See smithy-lang/smithy-typescript#733
This could also solve #15
riywo commented
Let me craft a PoC package.
riywo commented
This simple script worked:
const fs = require("fs");
fs.rmSync("build", { force: true, recursive: true });
fs.cpSync("node_modules/re2-wasm/build", "build", { recursive: true });
const wasm = fs.readFileSync("build/wasm/re2.wasm").toString("base64");
const js = fs.readFileSync("build/wasm/re2.js", { encoding: "utf8" });
fs.writeFileSync(
"build/wasm/re2.js",
`
var Module = {
wasmBinary: Buffer.from("${wasm}", "base64"),
}
${js}
`
);
fs.rmSync("build/wasm/re2.wasm");