Skip to content

Add npm package with WASM + TypeScript wrapper#6

Merged
MickeyShnaiderman-RecoLabs merged 1 commit into
mainfrom
feat/npm-package
Mar 30, 2026
Merged

Add npm package with WASM + TypeScript wrapper#6
MickeyShnaiderman-RecoLabs merged 1 commit into
mainfrom
feat/npm-package

Conversation

@MickeyShnaiderman-RecoLabs
Copy link
Copy Markdown
Collaborator

@MickeyShnaiderman-RecoLabs MickeyShnaiderman-RecoLabs commented Mar 30, 2026

Summary

Ship gnata WASM as an npm package (gnata) for browser consumption.

  • npm/: TypeScript package source with jsonata()-compatible API
  • scripts/build-npm.sh: Builds gnata.wasm + copies wasm_exec.js from Go toolchain, then compiles TypeScript
  • .github/workflows/publish-npm.yml: Publishes to npm on tag push via OIDC Trusted Publishing (no long-lived tokens, automatic provenance attestations)

The package:

  • Lazy-loads gnata.wasm + wasm_exec.js on first evaluation
  • Falls back to jsonata npm (optional peer dep) when WASM is unavailable
  • Exposes configure() for custom asset URLs
  • Correctly preserves null vs undefined semantics through the Go WASM boundary

How consumers use it

npm install gnata
import { jsonata } from 'gnata';
const result = await jsonata('Account.Order.Price').evaluate(data);

Assets (gnata.wasm, wasm_exec.js) need to be served at /wasm/ — use rspack/webpack CopyPlugin or similar.

Test plan

  • scripts/build-npm.sh builds WASM + TypeScript successfully
  • TypeScript compiles with tsc --noEmit
  • First manual npm publish from local machine
  • Configure Trusted Publishing on npmjs.com
  • Verify tag-triggered CI publish works

@MickeyShnaiderman-RecoLabs MickeyShnaiderman-RecoLabs force-pushed the feat/npm-package branch 2 times, most recently from f5841aa to 2c6b623 Compare March 30, 2026 11:35
Ship gnata WASM as an npm package (gnata-js) for browser consumption.
Same Go evaluator as backend services, for expression parity.

- npm/: TypeScript package with jsonata()-compatible API
- scripts/build-npm.sh: builds WASM + TS in one step
- .github/workflows/publish-npm.yml: publishes on tag via OIDC

Made-with: Cursor
@MickeyShnaiderman-RecoLabs MickeyShnaiderman-RecoLabs merged commit 82ab3eb into main Mar 30, 2026
2 checks passed
@MickeyShnaiderman-RecoLabs MickeyShnaiderman-RecoLabs deleted the feat/npm-package branch March 30, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants