Skip to content

Commit 2ddd588

Browse files
committed
fix safari
1 parent 886c390 commit 2ddd588

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test.describe('SQLite cross-browser compatibility', () => {
4+
test('worker initializes and generates data', async ({ page }) => {
5+
await page.goto('/');
6+
7+
// Worker should become ready
8+
await expect(page.locator('.status.ready')).toBeVisible({ timeout: 30000 });
9+
10+
// Generate data
11+
await page.getByRole('button', { name: 'Generate' }).click();
12+
await expect(page.locator('.status')).toContainText('orders', { timeout: 30000 });
13+
14+
// Results table should appear (auto-runs query after generate)
15+
await expect(page.locator('.results-table')).toBeVisible({ timeout: 10000 });
16+
});
17+
});

playground/playwright.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from '@playwright/test';
1+
import { defineConfig, devices } from '@playwright/test';
22

33
export default defineConfig({
44
testDir: './e2e',
@@ -8,6 +8,11 @@ export default defineConfig({
88
baseURL: 'http://localhost:3848',
99
headless: true,
1010
},
11+
projects: [
12+
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
13+
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
14+
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
15+
],
1116
webServer: {
1217
command: 'pnpm dev --port 3848',
1318
port: 3848,

playground/src/sqlite/worker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/// <reference lib="webworker" />
22

33
import type { WorkerInMessage, WorkerOutMessage, DataPools } from './types';
4+
// Static import prevents WebKit from re-evaluating the worker module
5+
// when a dynamic import chunk loads (which resets module-level state).
6+
import initSqlJs from 'sql.js';
47

58
declare const self: DedicatedWorkerGlobalScope;
69

@@ -81,8 +84,6 @@ async function doInit(msg: { type: 'init'; wasmExecText: string; wasmBytes: Arra
8184
return r as string;
8285
};
8386

84-
// Load sql.js from installed package (Vite bundles this into the worker)
85-
const initSqlJs = (await import('sql.js')).default;
8687
const SQL: SqlJsStatic = await initSqlJs({
8788
locateFile: (f: string) => 'https://cdn.jsdelivr.net/npm/sql.js@1/dist/' + f,
8889
});

0 commit comments

Comments
 (0)