Last active
November 13, 2022 10:36
-
-
Save kkebo/b5522a97f8b3c188628dccb1087a0ab7 to your computer and use it in GitHub Desktop.
@wasmer/[email protected] で swift-format.wasm のリリースビルドバイナリが実行できない再現コード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs-extra') | |
const { WASI } = require('@wasmer/wasi') | |
const wasiBindings = require('@wasmer/wasi/lib/bindings/node') | |
const { lowerI64Imports } = require("@wasmer/wasm-transformer") | |
const wasi = new WASI({ | |
args: ['swift-format', '--version'], | |
env: {}, | |
bindings: wasiBindings.default, | |
preopens: {'.': '.'} | |
}) | |
;(async () => { | |
const bytes = fs.readFileSync('./swift-format.wasm') | |
const loweredWasmBytes = lowerI64Imports(bytes) | |
const module = await WebAssembly.compile(loweredWasmBytes) | |
// ↓これなら OK | |
// const module = await WebAssembly.compile(bytes) | |
const instance = await WebAssembly.instantiate(module, wasi.getImports(module)) | |
wasi.start(instance) | |
})() |
Author
kkebo
commented
Nov 13, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment