Skip to content

Commit 1b73323

Browse files
start declaring modules
1 parent 47a2302 commit 1b73323

44 files changed

Lines changed: 173 additions & 125 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"format": "prettier --write .",
2121
"lint": "eslint .",
2222
"release": "pnpm build:packages:prod && pnpm changeset publish",
23-
"test": "pnpm run -r --workspace-concurrency=0 test"
23+
"test": "pnpm run -r --workspace-concurrency=1 test --run"
2424
},
2525
"keywords": [],
2626
"type": "module",

packages/attachments/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,24 @@
1616
"url": "https://github.com/powersync-ja/powersync-js/issues"
1717
},
1818
"description": "An PowerSync library to manage attachments for TypeScript and React Native apps",
19+
"type": "module",
1920
"main": "./lib/index.js",
21+
"module": "./lib/index.js",
2022
"types": "./lib/index.d.ts",
23+
"exports": {
24+
".": {
25+
"types": "./lib/index.d.ts",
26+
"import": "./lib/index.js",
27+
"default": "./lib/index.js"
28+
}
29+
},
2130
"files": [
2231
"lib"
2332
],
2433
"scripts": {
2534
"build": "tsc -b",
2635
"build:prod": "tsc -b --sourceMap false",
27-
"clean": "rm -rf lib tsconfig.tsbuildinfo node_modules",
36+
"clean": "rm -rf lib",
2837
"watch": "tsc -b -w",
2938
"test": "pnpm build && vitest"
3039
},

packages/attachments/src/AbstractAttachmentQueue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AbstractPowerSyncDatabase, Transaction } from '@powersync/common';
2-
import { ATTACHMENT_TABLE, AttachmentRecord, AttachmentState } from './Schema';
3-
import { EncodingType, StorageAdapter } from './StorageAdapter';
2+
import { ATTACHMENT_TABLE, AttachmentRecord, AttachmentState } from './Schema.js';
3+
import { EncodingType, StorageAdapter } from './StorageAdapter.js';
44

55
export interface AttachmentQueueOptions {
66
powersync: AbstractPowerSyncDatabase;

packages/attachments/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from './Schema';
2-
export * from './StorageAdapter';
1+
export * from './Schema.js';
2+
export * from './StorageAdapter.js';
33

4-
export * from './AbstractAttachmentQueue';
4+
export * from './AbstractAttachmentQueue.js';

packages/attachments/tests/attachments/AttachmentQueue.test.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
import * as commonSdk from '@powersync/common';
21
import { beforeEach, describe, expect, it, vi } from 'vitest';
3-
import { AbstractAttachmentQueue } from '../../src/AbstractAttachmentQueue';
4-
import { AttachmentRecord, AttachmentState } from '../../src/Schema';
5-
import { AbstractPowerSyncDatabase } from '@powersync/common';
6-
import { StorageAdapter } from '../../src/StorageAdapter';
2+
import { AbstractAttachmentQueue } from '../../src/AbstractAttachmentQueue.js';
3+
import { AttachmentRecord, AttachmentState } from '../../src/Schema.js';
4+
import { StorageAdapter } from '../../src/StorageAdapter.js';
75

86
const record = {
97
id: 'test-1',
108
filename: 'test.jpg',
119
state: AttachmentState.QUEUED_DOWNLOAD
12-
}
10+
};
1311

1412
const mockPowerSync = {
1513
currentStatus: { status: 'initial' },
1614
registerListener: vi.fn(() => {}),
1715
resolveTables: vi.fn(() => ['table1', 'table2']),
1816
onChangeWithCallback: vi.fn(),
19-
getAll: vi.fn(() => Promise.resolve([{id: 'test-1'}, {id: 'test-2'}])),
17+
getAll: vi.fn(() => Promise.resolve([{ id: 'test-1' }, { id: 'test-2' }])),
2018
execute: vi.fn(() => Promise.resolve()),
2119
getOptional: vi.fn((_query, params) => Promise.resolve(record)),
2220
watch: vi.fn((query, params, callbacks) => {
23-
callbacks?.onResult?.({ rows: { _array: [{id: 'test-1'}, {id: 'test-2'}] } });
21+
callbacks?.onResult?.({ rows: { _array: [{ id: 'test-1' }, { id: 'test-2' }] } });
2422
}),
2523
writeTransaction: vi.fn(async (callback) => {
2624
await callback({
@@ -57,9 +55,9 @@ describe('attachments', () => {
5755

5856
it('should not download attachments when downloadRecord is called with downloadAttachments false', async () => {
5957
const queue = new TestAttachmentQueue({
60-
powersync: mockPowerSync as any,
61-
storage: mockStorage,
62-
downloadAttachments: false
58+
powersync: mockPowerSync as any,
59+
storage: mockStorage,
60+
downloadAttachments: false
6361
});
6462

6563
await queue.downloadRecord(record);
@@ -69,9 +67,9 @@ describe('attachments', () => {
6967

7068
it('should download attachments when downloadRecord is called with downloadAttachments true', async () => {
7169
const queue = new TestAttachmentQueue({
72-
powersync: mockPowerSync as any,
73-
storage: mockStorage,
74-
downloadAttachments: true
70+
powersync: mockPowerSync as any,
71+
storage: mockStorage,
72+
downloadAttachments: true
7573
});
7674

7775
await queue.downloadRecord(record);
@@ -82,9 +80,9 @@ describe('attachments', () => {
8280
// Testing the inverse of this test, i.e. when downloadAttachments is false, is not required as you can't wait for something that does not happen
8381
it('should not download attachments with watchDownloads is called with downloadAttachments false', async () => {
8482
const queue = new TestAttachmentQueue({
85-
powersync: mockPowerSync as any,
86-
storage: mockStorage,
87-
downloadAttachments: true
83+
powersync: mockPowerSync as any,
84+
storage: mockStorage,
85+
downloadAttachments: true
8886
});
8987

9088
queue.watchDownloads();

packages/attachments/tsconfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
"extends": "../../tsconfig.base",
33
"compilerOptions": {
44
"baseUrl": "./",
5-
"jsx": "react",
65
"rootDir": "src",
7-
"outDir": "./lib"
6+
"module": "node16",
7+
"moduleResolution": "node16",
8+
"target": "es6",
9+
"outDir": "./lib",
10+
"tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo"
811
},
912
"references": [
1013
{

packages/common/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"types": "lib/index.d.ts",
1313
"exports": {
1414
".": {
15+
"types": "./lib/index.d.ts",
1516
"import": "./dist/bundle.mjs",
1617
"require": "./dist/bundle.cjs",
17-
"types": "./lib/index.d.ts",
1818
"default": "./dist/bundle.mjs"
1919
}
2020
},
@@ -35,7 +35,7 @@
3535
"scripts": {
3636
"build": "tsc -b && rollup -c rollup.config.mjs",
3737
"build:prod": "tsc -b --sourceMap false && rollup -c rollup.config.mjs --sourceMap false",
38-
"clean": "rm -rf lib dist tsconfig.tsbuildinfo node_modules",
38+
"clean": "rm -rf lib dist",
3939
"test": "vitest"
4040
},
4141
"dependencies": {

packages/common/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"preserveConstEnums": true,
1414
"esModuleInterop": false,
1515
"skipLibCheck": false,
16-
"strictNullChecks": true
16+
"strictNullChecks": true,
17+
"tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo"
1718
},
1819
"include": ["src/**/*"]
1920
}

packages/drizzle-driver/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
"name": "@powersync/drizzle-driver",
33
"version": "0.4.0",
44
"description": "Drizzle driver for PowerSync",
5+
"type": "module",
56
"main": "lib/src/index.js",
7+
"module": "lib/src/index.js",
68
"types": "lib/src/index.d.ts",
9+
"exports": {
10+
".": {
11+
"types": "./lib/src/index.d.ts",
12+
"import": "./lib/src/index.js",
13+
"default": "./lib/src/index.js"
14+
}
15+
},
716
"author": "JOURNEYAPPS",
817
"license": "Apache-2.0",
918
"files": [
@@ -21,7 +30,7 @@
2130
"scripts": {
2231
"build": "tsc --build",
2332
"build:prod": "tsc --build --sourceMap false",
24-
"clean": "rm -rf lib tsconfig.tsbuildinfo",
33+
"clean": "rm -rf lib",
2534
"watch": "tsc --build -w",
2635
"test": "vitest"
2736
},

packages/drizzle-driver/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import {
22
wrapPowerSyncWithDrizzle,
33
type DrizzleQuery,
44
type PowerSyncSQLiteDatabase
5-
} from './sqlite/PowerSyncSQLiteDatabase';
6-
import { toCompilableQuery } from './utils/compilableQuery';
5+
} from './sqlite/PowerSyncSQLiteDatabase.js';
6+
import { toCompilableQuery } from './utils/compilableQuery.js';
77
import {
88
DrizzleAppSchema,
99
toPowerSyncTable,
@@ -14,14 +14,14 @@ import {
1414
type ExtractPowerSyncColumns,
1515
type TableName,
1616
type TablesFromSchemaEntries
17-
} from './utils/schema';
17+
} from './utils/schema.js';
1818

1919
export {
2020
DrizzleAppSchema,
2121
DrizzleAppSchemaOptions,
22+
DrizzleQuery,
2223
DrizzleTablePowerSyncOptions,
2324
DrizzleTableWithPowerSyncOptions,
24-
DrizzleQuery,
2525
Expand,
2626
ExtractPowerSyncColumns,
2727
PowerSyncSQLiteDatabase,

0 commit comments

Comments
 (0)