General consumers of this library don't need to read any further. (The compiled files are available via the release page.)
If you want to compile your own version of SQLite for WebAssembly, or want to contribute to this project, read on.
This project defines a standardized development environment using Docker (and the .devcontainer spec in particular). This allows for anyone on any platform to get up and running quickly. (VSCode is not technically required to make use of this standardized environment, but it makes containerized development so seamless that the non-VSCode path is not currently documented here.)
Standardizing our development environment has numerous benefits:
- Allows anyone on ANY platform (Linux, Mac, and Windows) to contribute or compile their own build.
- It's quicker and easier for any contributor to dive in and fix issues.
- (Practically) eliminates configuration bugs that are difficult for maintainers to reproduce. Also known as "works on my machine" issues.
- Allows us to write our scripts assuming that they're always running in a single known environment of a single, known platform.
- Ensure that all contributors use a known, standardized installation of EMSDK.
- Allows for a more clearly documented process for updating the EMSDK to a new version.
- End-Users that simply want to compile and install their own version of SQLite don't have to bother with EMSDK installation in their particular environment.
To get started:
- Follow the Installation Steps for Containerized Development in VSCode. This includes installing Docker, VSCode, and the Remote Development extension pack for VSCode)
- Clone this repository
- Open the repository folder in VSCode. It will detect the presence of a .devcontainer and prompt you: "Folder contains a Dev Container configuration file. Reopen folder to develop in a container." Click "Reopen in container"
You're now ready to test the dev environment:
- Click on Terminal->New Terminal to be dropped into a terminal inside the dev environment.
- Run
$ npm installto install the required modules - Run
$ npm testto ensure all tests pass - Run
$ npm run rebuildto re-compile the project from scratch (using the version of EMSDK installed in the container). - Run
$ npm testto ensure all tests pass after said rebuild
You're now ready for development!
If you're on a Mac or Linux-based host machine, you can install and use the EMSDK directly to perform a build. Note that if you run into bugs with this configuration, we highly encourage you to use the containerized development environment instead, as detailed above.
Instructions:
- Install the EMSDK
- Clone this repository
- Run
$ npm installto install the required modules - Run
$ npm testto ensure all tests pass - Run
$ npm run rebuildto re-compile the project from scratch (using the version of EMSDK installed in the container). - Run
$ npm testto ensure all tests pass after said rebuild
The build depends on more than npm packages. See DEPENDENCIES.md
for the compiler, SQLite source, container, CI actions, release tools, CDN assets,
and transitive dependencies that need to be reviewed together. CI uses the Node
24 LTS version pinned in .node-version; the devcontainer supplies the same
Node major and the pinned Emscripten SDK.
In order to enable extensions like FTS5, change the CFLAGS in the Makefile and run npm run rebuild:
CFLAGS = \
-O2 \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_DISABLE_LFS \
-DSQLITE_ENABLE_FTS3 \
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
+ -DSQLITE_ENABLE_FTS5 \
-DSQLITE_THREADSAFE=0npm run build produces the default, browser-only, and inline WebAssembly builds, their debug variants, and worker bundles. The inline variants use Emscripten's -sSINGLE_FILE=1 to embed the binary in JavaScript.
To build only the inline variants:
make dist/sql-wasm-inline.js dist/sql-wasm-inline-debug.js dist/worker.sql-wasm-inline.js dist/worker.sql-wasm-inline-debug.jsnpm test runs the API suite against the WebAssembly variants and checks the distribution behavior, including single-file initialization without fetching a companion asset. npm run doc generates the API documentation.