fix(desktop): hide bun:sqlite import from Node.js/Electron ESM loader
Uses new Function() to prevent the static ESM loader from seeing the bun: protocol import at parse time. In Electron/Node.js, the import() call is evaluated at runtime and gracefully returns null when bun:sqlite is unavailable. Fixes #3829, likely fixes #3762
This commit is contained in:
@@ -13,7 +13,9 @@ describe("scheduleDeferredModelOverride bun:sqlite unavailable", () => {
|
||||
|
||||
//#then
|
||||
expect(hasStaticBunSqliteImport).toBe(false)
|
||||
expect(source).toContain('await import("bun:sqlite").catch(() => null)')
|
||||
// new Function() hides the bun: import from Node.js/Electron static ESM loader
|
||||
expect(source).toContain("new Function(\"return import('bun:sqlite')\")")
|
||||
expect(source).toContain("typeof globalThis.Bun === \"undefined\"")
|
||||
expect(source).toContain("bun:sqlite unavailable")
|
||||
expect(source).toContain("return")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user