npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wa-spatialite

v0.0.1

Published

SpatiaLite (GEOS, PROJ) linked into wa-sqlite as a single WebAssembly module for the browser or workers.

Readme

wa-spatialite

SpatiaLite (with GEOS and PROJ) linked into wa-sqlite as a single WebAssembly module. SQLite runs in the browser or a worker with the same JS API as upstream wa-sqlite, plus SpatiaLite SQL and geometry functions.

What you get

  • Static link: libspatialite, GEOS, PROJ, and zlib are compiled with Emscripten and linked into the wa-sqlite .mjs / .wasm outputs (no dynamic extension loading).
  • Three builds: sync (wa-sqlite.mjs), Asyncify (wa-sqlite-async.mjs), and JSPI (wa-sqlite-jspi.mjs), matching upstream wa-sqlite.
  • Bridge: src/spatialite_init.c registers SpatiaLite via sqlite3_auto_extension. You must call the exported core_init once after the module loads (see below).
  • Demo: Vite dev server under demo/ that runs sample SpatiaLite SQL in the browser.

Prerequisites

Native / WASM build (make)

  • Emscripten (emcc, em++, emcmake, emmake, emar)
  • cmake, make, python3, curl, openssl
  • A sqlite3 CLI on your PATH (PROJ’s build uses it to assemble proj.db)

Demo (npm run demo)

  • Node.js 18+
  • A completed WASM build so dist/wa-sqlite.mjs and dist/wa-sqlite.wasm exist

Clone

This repo uses submodules:

git clone <repo-url> wa-spatialite
cd wa-spatialite
git submodule update --init --recursive

Vendored trees include wa-sqlite, libspatialite, GEOS, and PROJ under vendor/.

Build (WASM)

From the repository root:

make wasm-spatialite-sync

Produces dist/wa-sqlite.mjs and dist/wa-sqlite.wasm (sync build with SpatiaLite).

Other useful targets:

| Target | Purpose | |--------|---------| | make / make wasm-spatialite | Sync + async + JSPI variants; copies all into ./dist/ | | make wasm-spatialite-sync | Sync only → ./dist/ | | make wasm-spatialite-async | Asyncify variant | | make wasm-spatialite-jspi | JSPI variant | | make wasm-geos | GEOS only → build/wasm/ | | make wasm-proj | PROJ only | | make wasm-libspatialite | libspatialite only | | make clean-wasm | Remove build/wasm, build/geos, build/proj, build/libspatialite, staging, etc. |

Intermediate install prefix: build/wasm/ (static libraries and headers).

libspatialite feature set

The Makefile configures a minimal libspatialite (fewer native dependencies): among other flags, libxml2, MiniZIP, FreeXL, iconv, GeoPackage, RTTOPO, and GCP are disabled. Enable more features only if you add the corresponding WASM-capable dependencies and adjust configure options.

Submodule caveats

  • emconfigure does not forward PKG_CONFIG_PATH; the Makefile sets EM_PKG_CONFIG_PATH so sqlite3.pc is found.
  • The libspatialite fork may ship configure / install-sh without execute bits; the Makefile runs chmod +x where needed.
  • A stale gaiaconfig.h in the submodule can shadow the real configure output; the Makefile copies the generated header from the build tree after configure.

Using from JavaScript

  1. Load the Emscripten factory (same pattern as wa-sqlite).
  2. Instantiate the module; pass locateFile if your .wasm is not next to the .mjs.
  3. Call core_init once (exported as _core_init / ccall('core_init', …)).
  4. Build the JS API with Factory(module) from vendor/wa-sqlite/src/sqlite-api.js and open databases as usual.

Example (sync build, paths illustrative):

import * as SQLite from "./vendor/wa-sqlite/src/sqlite-api.js";
import mjsUrl from "./dist/wa-sqlite.mjs?url";   // or your bundler’s equivalent
import wasmUrl from "./dist/wa-sqlite.wasm?url";

const { default: createModule } = await import(mjsUrl);
const module = await createModule({
  locateFile: (path) => (path.endsWith(".wasm") ? wasmUrl : path),
});

const rc = module.ccall("core_init", "number", ["string"], [""]);
if (rc !== 0) throw new Error("core_init failed");

const sqlite3 = SQLite.Factory(module);
const db = await sqlite3.open_v2(":memory:");
await sqlite3.exec(db, "SELECT spatialite_version();", (row, cols) => {
  console.log(cols, row);
});
await sqlite3.close(db);

The demo app uses Vite ?url imports so the bundle is not loaded from the public/ folder (which Vite reserves for non-imported static files).

Demo (web dev server)

make wasm-spatialite-sync   # once, if dist/ is empty
npm install
npm run demo

Opens http://localhost:8080 (see vite.config.ts). The page runs sample SQL (spatialite_version, MakePoint, etc.) against an in-memory database.

Production build of the demo:

npm run demo    # optional: verify dev
npx vite build  # output under demo/dist/
npm run demo:preview

License

MIT (see LICENSE). Third-party code in vendor/ retains its own licenses.