@birchill/nice-sqlite-wasm 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,6 +15,9 @@ It's "nice" because:
15
15
  In general, it should be nicer for apps using bundlers that only need the
16
16
  "opfs-sahpool" VFS.
17
17
 
18
+ As an extra bonus, the whole build (including building the WASM module) is done
19
+ in CI and published to npm with provenance data so you get full traceability.
20
+
18
21
  > [!NOTE]
19
22
  > The JS/WASM part of SQLite is under heavy development and is expected to
20
23
  > change a lot in future (e.g. using WASI instead of Emscripten). As a result
@@ -25,7 +28,116 @@ For the official SQLite WASM package see
25
28
 
26
29
  ## Usage
27
30
 
28
- TODO
31
+ Install:
32
+
33
+ ```
34
+ npm install @birchill/nice-sqlite-wasm
35
+ ```
36
+
37
+ You _could_ probably just do an `import sqlite3InitModule from
38
+ '@birchill/nice-sqlite-wasm'` and be done with it but the whole point of this
39
+ module is to allow you to set it up for better caching and pre-loading.
40
+ How you do that will depend on your bundler.
41
+
42
+ Following is an example for [rspack](https://rspack.rs).
43
+
44
+ ### rspack
45
+
46
+ First, we set up a way to generated the name of the WASM module so we can pass
47
+ it to `sqlite3InitModule`.
48
+
49
+ In your `rspack.config.js`:
50
+
51
+ ```js
52
+ export default defineConfig((env) => {
53
+ // ...
54
+ module: {
55
+ rules: [
56
+ { resourceQuery: /url$/, type: 'asset/resource' },
57
+ ],
58
+ },
59
+ });
60
+ ```
61
+
62
+ Second, we set up rspack to produce the desired output filename for the asset,
63
+ otherwise you'll get something like `[hash].wasm` which isn't very helpful.
64
+
65
+ Furthermore, we want to drop the query string we enabled above.
66
+
67
+ ```js
68
+ export default defineConfig((env) => {
69
+ // ...
70
+ output: {
71
+ assetModuleFilename: (fileInfo) => {
72
+ // Generate a cacheable but readable filename for WASM files
73
+ if (
74
+ fileInfo.filename.endsWith('.wasm') ||
75
+ fileInfo.filename.endsWith('.wasm?url')
76
+ ) {
77
+ return '[name].[hash].wasm';
78
+ }
79
+ return '[hash][ext][query]';
80
+ },
81
+ },
82
+ });
83
+ ```
84
+
85
+ Then in your worker code:
86
+
87
+ ```js
88
+ import wasmUrl from '@birchill/nice-sqlite-wasm/sqlite3.wasm?url';
89
+ import sqlite3InitModule from '@birchill/nice-sqlite-wasm';
90
+ ```
91
+
92
+ Then when you initialize SQLite:
93
+
94
+ ```js
95
+ const sqlite = await sqlite3InitModule({
96
+ // Override SQLite's locateFile implementation which wants to resolve
97
+ // the SQLite WASM binary relative to the source directory instead of
98
+ // the asset name assigned by rspack.
99
+ locateFile: (file) => {
100
+ if (file === 'sqlite3.wasm') {
101
+ // Since we strip the query string in our `assetModuleFilename`
102
+ // option in rspack.config.js we don't need to worry about dropping
103
+ // it here.
104
+ //
105
+ // If we were to stop doing that, however, we'd need to do
106
+ // something like:
107
+ //
108
+ // return new URL(wasmUrl, self.location.href).pathname;
109
+ //
110
+ // instead.
111
+ return fetch(wasmUrl, {
112
+ credentials: 'same-origin',
113
+ // If you want to make the fetch abortable...
114
+ signal: abortController.signal,
115
+ });
116
+ } else {
117
+ throw new Error(`Unknown file: ${file}`);
118
+ }
119
+ },
120
+ });
121
+ ```
122
+
123
+ You can also just return `wasmUrl` from `locateFile` if don't need to control
124
+ the fetch yourself.
125
+
126
+ ### vite
127
+
128
+ I'm not sure how to configure vite, but if you're only using it for testing
129
+ (i.e. using [vitest](https://vitest.dev/)) then you can just disable
130
+ optimization there as [explained in the official WASM
131
+ module docs](https://github.com/sqlite/sqlite-wasm/#usage-with-vite):
132
+
133
+ ```js
134
+ // vitest.config.js
135
+ import { defineConfig } from 'vite';
136
+
137
+ export default defineConfig({
138
+ optimizeDeps: { exclude: ['@birchill/nice-sqlite-wasm'] },
139
+ });
140
+ ```
29
141
 
30
142
  ## Developing
31
143
 
@@ -0,0 +1 @@
1
+ ba76c160c735437de974c6ea24c890a663214c6b
package/dist/sqlite3.js CHANGED
@@ -26,11 +26,11 @@
26
26
  /*
27
27
  ** This code was built from sqlite3 version...
28
28
  **
29
- ** SQLITE_VERSION "3.51.1"
30
- ** SQLITE_VERSION_NUMBER 3051001
31
- ** SQLITE_SOURCE_ID "2025-11-28 17:28:25 281fc0e9afc38674b9b0991943b9e9d1e64c6cbdb133d35f6f5c87ff6af3alt1"
29
+ ** SQLITE_VERSION "3.51.2"
30
+ ** SQLITE_VERSION_NUMBER 3051002
31
+ ** SQLITE_SOURCE_ID "2026-01-09 17:27:48 b270f8339eb13b504d0b2ba154ebca966b7dde08e40c3ed7d559749818cbalt1"
32
32
  **
33
- ** Emscripten SDK: 4.0.23
33
+ ** Emscripten SDK: 5.0.0
34
34
  **
35
35
  */
36
36
 
@@ -9719,17 +9719,17 @@ async function sqlite3InitModule(moduleArg = {}) {
9719
9719
  });
9720
9720
  globalThis.sqlite3ApiBootstrap.initializers.push(function (sqlite3) {
9721
9721
  sqlite3.version = {
9722
- libVersion: '3.51.1',
9723
- libVersionNumber: 3051001,
9722
+ libVersion: '3.51.2',
9723
+ libVersionNumber: 3051002,
9724
9724
  sourceId:
9725
- '2025-11-28 17:28:25 281fc0e9afc38674b9b0991943b9e9d1e64c6cbdb133d35f6f5c87ff6af3alt1',
9726
- downloadVersion: 3510100,
9725
+ '2026-01-09 17:27:48 b270f8339eb13b504d0b2ba154ebca966b7dde08e40c3ed7d559749818cbalt1',
9726
+ downloadVersion: 3510200,
9727
9727
  scm: {
9728
9728
  'sha3-256':
9729
- '281fc0e9afc38674b9b0991943b9e9d1e64c6cbdb133d35f6f5c87ff6af3alt1',
9729
+ 'b270f8339eb13b504d0b2ba154ebca966b7dde08e40c3ed7d559749818cbalt1',
9730
9730
  branch: 'branch-3.51',
9731
- tags: 'release version-3.51.1',
9732
- datetime: '2025-11-28T17:28:25.933Z',
9731
+ tags: 'release version-3.51.2',
9732
+ datetime: '2026-01-09T17:27:48.405Z',
9733
9733
  },
9734
9734
  };
9735
9735
  });
@@ -10264,11 +10264,11 @@ async function sqlite3InitModule(moduleArg = {}) {
10264
10264
  stmt = null;
10265
10265
  }
10266
10266
  } finally {
10267
- wasm.scopedAllocPop(stack);
10268
10267
  if (stmt) {
10269
10268
  __execLock.delete(stmt);
10270
10269
  stmt.finalize();
10271
10270
  }
10271
+ wasm.scopedAllocPop(stack);
10272
10272
  }
10273
10273
  return arg.returnVal();
10274
10274
  },
package/dist/sqlite3.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@birchill/nice-sqlite-wasm",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,5 +23,5 @@
23
23
  "publishConfig": {
24
24
  "provenance": true
25
25
  },
26
- "publishedAt": "2026-01-14T05:14:37.216Z"
26
+ "publishedAt": "2026-01-26T07:39:51.875Z"
27
27
  }