File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,19 +31,6 @@ const start = function (sqlite3) {
3131 }
3232} ;
3333
34- // Mock fetch because Emscripten's Node.js loader still uses it and it fails on file:// URLs
35- globalThis . fetch = async ( url ) => {
36- if ( url . toString ( ) . endsWith ( '.wasm' ) ) {
37- const buffer = readFileSync (
38- new URL ( '../dist/sqlite3.wasm' , import . meta. url ) ,
39- ) ;
40- return new Response ( buffer , {
41- headers : { 'Content-Type' : 'application/wasm' } ,
42- } ) ;
43- }
44- throw new Error ( `Unexpected fetch to ${ url } ` ) ;
45- } ;
46-
4734log ( 'Loading and initializing SQLite3 module...' ) ;
4835sqlite3InitModule ( {
4936 print : log ,
Original file line number Diff line number Diff line change 1- import { expect , test , vi } from 'vitest' ;
2- import { readFileSync } from 'node:fs' ;
1+ import { expect , test } from 'vitest' ;
32import sqlite3InitModule from '../bin/sqlite3-node.mjs' ;
43
54test ( 'Node.js build sanity check' , async ( ) => {
6- // Mock fetch because Emscripten's Node.js loader still uses it, and it fails on file:// URLs
7- vi . stubGlobal ( 'fetch' , async ( url ) => {
8- if ( url . endsWith ( '.wasm' ) ) {
9- const buffer = readFileSync (
10- new URL ( '../bin/sqlite3.wasm' , import . meta. url ) ,
11- ) ;
12- return new Response ( buffer , {
13- headers : { 'Content-Type' : 'application/wasm' } ,
14- } ) ;
15- }
16- throw new Error ( `Unexpected fetch to ${ url } ` ) ;
17- } ) ;
18-
195 const sqlite3 = await sqlite3InitModule ( ) ;
206
217 expect ( typeof sqlite3 . version . libVersion ) . toBe ( 'string' ) ;
You can’t perform that action at this time.
0 commit comments