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 --- integration/bunjs-only-snippets/transpiler.test.js | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'integration/bunjs-only-snippets/transpiler.test.js') diff --git a/integration/bunjs-only-snippets/transpiler.test.js b/integration/bunjs-only-snippets/transpiler.test.js index 3d2064f72..61024e400 100644 --- a/integration/bunjs-only-snippets/transpiler.test.js +++ b/integration/bunjs-only-snippets/transpiler.test.js @@ -629,6 +629,40 @@ describe("Bun.Transpiler", () => { ); }); + describe("Bun.js", () => { + it("require -> import.meta.require", () => { + expectBunPrinted_( + `export const foo = require('bar.node')`, + `export const foo = import.meta.require("bar.node")` + ); + }); + + it("require.resolve -> import.meta.resolveSync", () => { + expectBunPrinted_( + `export const foo = require.resolve('bar.node')`, + `export const foo = import.meta.resolveSync("bar.node")` + ); + }); + + it('require.resolve(path, {paths: ["blah"]}) -> import.meta.resolveSync', () => { + expectBunPrinted_( + `export const foo = require.resolve('bar.node', {paths: ["blah"]})`, + `export const foo = import.meta.resolveSync("bar.node", { paths: ["blah"] })` + ); + }); + }); + + describe("Browsers", () => { + it('require.resolve("my-module") -> "/resolved/my-module"', () => { + // the module resolver & linker doesn't run with Bun.Transpiler + // so in this test, it becomes the same path string + expectPrinted_( + `export const foo = require.resolve('my-module')`, + `export const foo = "my-module"` + ); + }); + }); + it("define", () => { expectPrinted_( `export default typeof user_undefined === 'undefined';`, -- cgit v1.2.3