From 40f517b03fc9af8b28761caede80b886efa98600 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Wed, 13 Nov 2024 11:28:22 +0200 Subject: [PATCH] Fix Wasm packaging The `wasm-pack` too has a known bug where it forgets to add snippets to `package.json`: https://github.com/rustwasm/wasm-pack/issues/1206 Let's fix that with some bash magic. --- bindings/wasm/README.md | 9 +++++++++ bindings/wasm/examples/example.js | 2 +- bindings/wasm/package.json | 20 ++++++++++++++++++++ bindings/wasm/scripts/build | 4 ++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 bindings/wasm/README.md create mode 100644 bindings/wasm/package.json create mode 100755 bindings/wasm/scripts/build diff --git a/bindings/wasm/README.md b/bindings/wasm/README.md new file mode 100644 index 000000000..7703ab4a8 --- /dev/null +++ b/bindings/wasm/README.md @@ -0,0 +1,9 @@ +# Limbo Wasm bindings + +This source tree contains Limbo Wasm bindings. + +## Building + +``` +./scripts/build +``` diff --git a/bindings/wasm/examples/example.js b/bindings/wasm/examples/example.js index 30c2dadf7..0ebee33a7 100644 --- a/bindings/wasm/examples/example.js +++ b/bindings/wasm/examples/example.js @@ -2,4 +2,4 @@ import { Database } from 'limbo-wasm'; const db = new Database('hello.db'); -db.exec("SELECT 'hello, world' AS message"); +console.log(db.exec("SELECT 'hello, world' AS message")); diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json new file mode 100644 index 000000000..e8ae29896 --- /dev/null +++ b/bindings/wasm/package.json @@ -0,0 +1,20 @@ +{ + "name": "limbo-wasm", + "collaborators": [ + "the Limbo authors" + ], + "version": "0.0.4", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/penberg/limbo" + }, + "files": [ + "snippets", + "limbo_wasm_bg.wasm", + "limbo_wasm.js", + "limbo_wasm.d.ts" + ], + "main": "limbo_wasm.js", + "types": "limbo_wasm.d.ts" +} diff --git a/bindings/wasm/scripts/build b/bindings/wasm/scripts/build new file mode 100755 index 000000000..23f2b8b93 --- /dev/null +++ b/bindings/wasm/scripts/build @@ -0,0 +1,4 @@ +#!/bin/bash + +wasm-pack build --no-pack --target nodejs +cp package.json pkg/package.json