From a37f86e89dc01f884a1b4474c27c79d5932093a0 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 16 May 2022 15:46:20 -0700 Subject: `bun:sqlite` (#167) * :scissors: * Add the slow version * draw the rest of the owl * Fix crash when allocating lots of memory * [Bun.Transipiler] Support passing objects * [JS Parser] Support passing objects to macros via Bun.Transpiler * Update JSSQLStatement.cpp * Embed SQLite * Add SQLite to Dockerfile * [sqlite] Add quick one-off queries without creating a whole object * [sqlite] Add `columnsCount`, rename raw() to `values()`, remove `rebind` * Implement `bun:sqlite` * return null * Fix updating query * Update bun.d.ts * more tests * Support variadic arguments, write tests and add types * Update sqlite.d.ts * Update sqlite.d.ts * latest * Implement `Database.loadExtension` and `Database.setCustomSQLite` * Support `require.resolve` * [napi] Improve string performance * [bun.js] Support some of `node:module` * another test * [sqlite] Support serialize & deserialize * [`bun:ffi`] Implement `CFunction` and `linkSymbols` * [bun.js] Fix crash in `Buffer.from` * Update sqlite.test.js * Document linkSymbols * docs * Update README.md --- src/javascript/jsc/javascript.zig | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/javascript/jsc/javascript.zig') diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index 24c82239a..9de25b756 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -1173,6 +1173,28 @@ pub const VirtualMachine = struct { .hash = 0, }; }, + .@"bun:sqlite" => { + return ResolvedSource{ + .allocator = null, + .source_code = ZigString.init( + @as(string, @embedFile("./bindings/sqlite/sqlite.exports.js")), + ), + .specifier = ZigString.init("bun:sqlite"), + .source_url = ZigString.init("bun:sqlite"), + .hash = 0, + }; + }, + .@"node:module" => { + return ResolvedSource{ + .allocator = null, + .source_code = ZigString.init( + @as(string, @embedFile("./module.exports.js")), + ), + .specifier = ZigString.init("node:module"), + .source_url = ZigString.init("node:module"), + .hash = 0, + }; + }, } } else if (_specifier.len > js_ast.Macro.namespaceWithColon.len and strings.eqlComptimeIgnoreLen(_specifier[0..js_ast.Macro.namespaceWithColon.len], js_ast.Macro.namespaceWithColon)) @@ -2891,6 +2913,8 @@ pub const HardcodedModule = enum { @"node:fs", @"node:path", @"detect-libc", + @"bun:sqlite", + @"node:module", pub const Map = bun.ComptimeStringMap( HardcodedModule, @@ -2905,6 +2929,9 @@ pub const HardcodedModule = enum { .{ "node:path/win32", HardcodedModule.@"node:path" }, .{ "node:path/posix", HardcodedModule.@"node:path" }, .{ "detect-libc", HardcodedModule.@"detect-libc" }, + .{ "bun:sqlite", HardcodedModule.@"bun:sqlite" }, + .{ "node:module", HardcodedModule.@"node:module" }, + .{ "module", HardcodedModule.@"node:module" }, }, ); pub const LinkerMap = bun.ComptimeStringMap( @@ -2919,6 +2946,9 @@ pub const HardcodedModule = enum { .{ "node:path", "node:path" }, .{ "path", "node:path" }, .{ "bun:wrap", "bun:wrap" }, + .{ "bun:sqlite", "bun:sqlite" }, + .{ "node:module", "node:module" }, + .{ "module", "node:module" }, }, ); }; -- cgit v1.2.3