bun-types 1.3.4-canary.20251202T140744 → 1.3.4-canary.20251204T140702
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/docs/bundler/executables.mdx +16 -2
- package/package.json +1 -1
|
@@ -412,7 +412,9 @@ const bytes = await file(icon).arrayBuffer();
|
|
|
412
412
|
|
|
413
413
|
### Embed SQLite databases
|
|
414
414
|
|
|
415
|
-
If your application wants to embed a SQLite database, set `type: "sqlite"` in the import attribute and the `embed` attribute to `"true"`.
|
|
415
|
+
If your application wants to embed a SQLite database into the compiled executable, set `type: "sqlite"` in the import attribute and the `embed` attribute to `"true"`.
|
|
416
|
+
|
|
417
|
+
The database file must already exist on disk. Then, import it in your code:
|
|
416
418
|
|
|
417
419
|
```ts index.ts icon="/icons/typescript.svg"
|
|
418
420
|
import myEmbeddedDb from "./my.db" with { type: "sqlite", embed: "true" };
|
|
@@ -420,7 +422,19 @@ import myEmbeddedDb from "./my.db" with { type: "sqlite", embed: "true" };
|
|
|
420
422
|
console.log(myEmbeddedDb.query("select * from users LIMIT 1").get());
|
|
421
423
|
```
|
|
422
424
|
|
|
423
|
-
|
|
425
|
+
Finally, compile it into a standalone executable:
|
|
426
|
+
|
|
427
|
+
```bash terminal icon="terminal"
|
|
428
|
+
bun build --compile ./index.ts --outfile mycli
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
<Note>
|
|
432
|
+
The database file must exist on disk when you run `bun build --compile`. The `embed: "true"` attribute tells the
|
|
433
|
+
bundler to include the database contents inside the compiled executable. When running normally with `bun run`, the
|
|
434
|
+
database file is loaded from disk just like a regular SQLite import.
|
|
435
|
+
</Note>
|
|
436
|
+
|
|
437
|
+
In the compiled executable, the embedded database is read-write, but all changes are lost when the executable exits (since it's stored in memory).
|
|
424
438
|
|
|
425
439
|
### Embed N-API Addons
|
|
426
440
|
|
package/package.json
CHANGED