Throwaway prototypes for Sausage v3. Plan and decisions: ~/research/sausage-v3/PLAN.md. Results and evidence: the spike READMEs.
30 lines
1.7 KiB
Nu
30 lines
1.7 KiB
Nu
# Build unpatched esbuild v0.27.7 and adapt it into a WASI component.
|
|
def main [] {
|
|
let root = '/tmp/s6-esbuild'
|
|
let fixture = $env.FILE_PWD
|
|
mkdir $root
|
|
if not ($root | path join esbuild | path exists) {
|
|
^git clone --depth 1 --branch v0.27.7 https://github.com/evanw/esbuild.git ($root | path join esbuild)
|
|
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'clone failed'} }
|
|
}
|
|
cd ($root | path join esbuild)
|
|
with-env {GOOS: wasip1, GOARCH: wasm} {
|
|
^go build -p 2 -trimpath '-ldflags=-s -w' -o ($root | path join esbuild.wasm) ./cmd/esbuild
|
|
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'WASI build failed'} }
|
|
}
|
|
^go build -p 2 -trimpath '-ldflags=-s -w' -o ($root | path join esbuild-native) ./cmd/esbuild
|
|
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'native build failed'} }
|
|
let adapter = ($root | path join adapter-v49.wasm)
|
|
if not ($adapter | path exists) {
|
|
^curl -fL https://github.com/bytecodealliance/wasmtime/releases/download/v49.0.2/wasi_snapshot_preview1.command.wasm -o $adapter
|
|
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'adapter download failed'} }
|
|
}
|
|
^wasm-tools component new ($root | path join esbuild.wasm) --adapt $'wasi_snapshot_preview1=($adapter)' -o ($root | path join esbuild.component.wasm)
|
|
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'component adaptation failed'} }
|
|
mkdir ($root | path join app)
|
|
cp ($fixture | path join app.tsx) ($fixture | path join check.mjs) ($fixture | path join package.json) ($fixture | path join package-lock.json) ($root | path join app)
|
|
cd ($root | path join app)
|
|
^npm ci --ignore-scripts --no-audit --no-fund
|
|
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'npm ci failed'} }
|
|
}
|