Skip to content

Commit

Permalink
Testing rollup common with tsc web.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriztiaan committed Jul 15, 2024
1 parent e410da0 commit a2cac24
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@powersync/web",
"version": "1.2.0",
"description": "A Web SDK for JourneyApps PowerSync",
"main": "dist/index.js",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"files": [
"lib",
Expand All @@ -19,7 +19,7 @@
},
"homepage": "https://docs.powersync.com",
"scripts": {
"build": "tsc --build && vite build",
"build": "tsc --build",
"clean": "rm -rf lib tsconfig.tsbuildinfo",
"watch": "tsc --build -w",
"test": "pnpm build && vitest"
Expand Down
18 changes: 9 additions & 9 deletions packages/web/src/db/sync/SharedWebStreamingSyncImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { AbstractSharedSyncClientProvider } from '../../worker/sync/AbstractSharedSyncClientProvider';
import { PowerSyncConnectionOptions, PowerSyncCredentials, SyncStatus, SyncStatusOptions } from '@powersync/common';
import { openWorkerDatabasePort } from '../../worker/db/open-worker-database';
import SharedSyncImplementationWorker from '../../worker/sync/SharedSyncImplementation.worker?sharedworker&inline';

/**
* The shared worker will trigger methods on this side of the message port
Expand Down Expand Up @@ -94,13 +93,14 @@ export class SharedWebStreamingSyncImplementation extends WebStreamingSyncImplem
* Configure or connect to the shared sync worker.
* This worker will manage all syncing operations remotely.
*/
const syncWorker = new SharedSyncImplementationWorker({ name: `shared-sync-${this.webOptions.identifier}` });

// new SharedWorker(new URL('../../worker/sync/SharedSyncImplementation.worker.js', import.meta.url), {
// /* @vite-ignore */
// name: `shared-sync-${this.webOptions.identifier}`,
// type: 'module'
// });
const syncWorker = new SharedWorker(
new URL('../../worker/sync/SharedSyncImplementation.worker.js', import.meta.url),
{
/* @vite-ignore */
name: `shared-sync-${this.webOptions.identifier}`,
type: 'module'
}
);
this.messagePort = syncWorker.port;
this.syncManager = Comlink.wrap<SharedSyncImplementation>(this.messagePort);
this.triggerCrudUpload = this.syncManager.triggerCrudUpload;
Expand All @@ -112,7 +112,7 @@ export class SharedWebStreamingSyncImplementation extends WebStreamingSyncImplem
* sync worker.
*/
const { crudUploadThrottleMs, identifier, retryDelayMs } = this.options;
const dbOpenerPort = openWorkerDatabasePort(this.options.identifier!, true) as any;
const dbOpenerPort = openWorkerDatabasePort(this.options.identifier!, true) as MessagePort;
this.isInitialized = this.syncManager.init(Comlink.transfer(dbOpenerPort, [dbOpenerPort]), {
dbName: this.options.identifier!,
streamOptions: {
Expand Down
24 changes: 11 additions & 13 deletions packages/web/src/worker/db/open-worker-database.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Comlink from 'comlink';
import type { OpenDB } from '../../shared/types';
import SharedPsWorker from './SharedWASQLiteDB.worker?sharedworker&inline';

/**
* Opens a shared or dedicated worker which exposes opening of database connections
Expand All @@ -12,18 +11,17 @@ export function openWorkerDatabasePort(workerIdentifier: string, multipleTabs =
* This enables multi tab support by default, but falls back if SharedWorker is not available
* (in the case of Android)
*/
return new SharedPsWorker({ name: `shared-DB-worker-${workerIdentifier}` }).port;
// return multipleTabs
// ? new SharedWorker(new URL('./SharedWASQLiteDB.worker.js', import.meta.url), {
// /* @vite-ignore */
// name: `shared-DB-worker-${workerIdentifier}`,
// type: 'module'
// }).port
// : new Worker(new URL('./WASQLiteDB.worker.js', import.meta.url), {
// /* @vite-ignore */
// name: `DB-worker-${workerIdentifier}`,
// type: 'module'
// });
return multipleTabs
? new SharedWorker(new URL('./SharedWASQLiteDB.worker.js', import.meta.url), {
/* @vite-ignore */
name: `shared-DB-worker-${workerIdentifier}`,
type: 'module'
}).port
: new Worker(new URL('./WASQLiteDB.worker.js', import.meta.url), {
/* @vite-ignore */
name: `DB-worker-${workerIdentifier}`,
type: 'module'
});
}

/**
Expand Down

0 comments on commit a2cac24

Please sign in to comment.