Skip to content

Commit 7ad251a

Browse files
Improve Exports (#686)
1 parent 623d79f commit 7ad251a

File tree

85 files changed

+1552
-1003
lines changed

Some content is hidden

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

85 files changed

+1552
-1003
lines changed

.changeset/kind-apricots-matter.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@powersync/drizzle-driver': minor
3+
'@powersync/kysely-driver': minor
4+
'@powersync/attachments': minor
5+
---
6+
7+
Updated package exports to reflect ESM exports. Added CommonJS exports.

.changeset/modern-feet-add.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@powersync/common': minor
3+
'@powersync/node': minor
4+
---
5+
6+
Added CJS specific type declarations.

.changeset/soft-swans-drive.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@powersync/tanstack-react-query': minor
3+
'@powersync/react': minor
4+
'@powersync/vue': minor
5+
---
6+
7+
Updated package exports to reflect ESM nature.

.changeset/unlucky-singers-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/react': minor
3+
---
4+
5+
Update package exports to reflect ESM exports.

.github/workflows/test-isolated.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
- name: Build Packages
4646
run: pnpm build:packages
4747

48+
- name: Test Package Exports
49+
run: pnpm test:packages:exports
50+
4851
- name: Start Verdaccio
4952
run: |
5053
npm install -g verdaccio

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
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",
24+
"test:packages:exports": "pnpm -r --filter {./packages/**} test:exports"
2425
},
2526
"keywords": [],
2627
"type": "module",
@@ -31,15 +32,21 @@
3132
},
3233
"devDependencies": {
3334
"@actions/core": "^1.10.1",
35+
"@arethetypeswrong/cli": "^0.18.2",
3436
"@changesets/cli": "2.27.2",
3537
"@pnpm/workspace.find-packages": "^4.0.2",
38+
"@rollup/plugin-commonjs": "^25.0.7",
39+
"@rollup/plugin-node-resolve": "15.2.3",
40+
"@rollup/plugin-typescript": "^12.1.4",
3641
"@vitest/browser": "^3.2.4",
3742
"husky": "^9.0.11",
3843
"lint-staged": "^15.2.2",
3944
"playwright": "^1.51.0",
4045
"prettier": "^3.2.5",
4146
"prettier-plugin-embed": "^0.4.15",
4247
"prettier-plugin-sql": "^0.18.1",
48+
"rollup": "4.14.3",
49+
"rollup-plugin-dts": "^6.2.1",
4350
"typescript": "^5.7.2",
4451
"vitest": "^3.2.4"
4552
}

packages/attachments/package.json

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,33 @@
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-
"main": "./lib/index.js",
19+
"type": "module",
20+
"main": "./dist/index.cjs",
21+
"module": "./lib/index.js",
2022
"types": "./lib/index.d.ts",
23+
"exports": {
24+
".": {
25+
"import": {
26+
"default": "./lib/index.js",
27+
"types": "./lib/index.d.ts"
28+
},
29+
"require": {
30+
"default": "./dist/index.cjs",
31+
"types": "./dist/index.d.cts"
32+
}
33+
}
34+
},
2135
"files": [
22-
"lib"
36+
"lib",
37+
"dist"
2338
],
2439
"scripts": {
25-
"build": "tsc -b",
26-
"build:prod": "tsc -b --sourceMap false",
27-
"clean": "rm -rf lib tsconfig.tsbuildinfo node_modules",
40+
"build": "tsc -b && rollup --config",
41+
"build:prod": "tsc -b --sourceMap false && rollup --config --sourceMap=false",
42+
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
2843
"watch": "tsc -b -w",
29-
"test": "pnpm build && vitest"
44+
"test": "pnpm build && vitest",
45+
"test:exports": "attw --pack ."
3046
},
3147
"peerDependencies": {
3248
"@powersync/common": "workspace:^1.35.0"

packages/attachments/rollup.config.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import commonjs from '@rollup/plugin-commonjs';
2+
import resolve from '@rollup/plugin-node-resolve';
3+
import typescript from '@rollup/plugin-typescript';
4+
import { dts } from 'rollup-plugin-dts';
5+
6+
/** @type {import('rollup').RollupOptions} */
7+
export default (commandLineArgs) => {
8+
const sourceMap = (commandLineArgs.sourceMap || 'true') == 'true';
9+
10+
// Clears rollup CLI warning https://github.com/rollup/rollup/issues/2694
11+
delete commandLineArgs.sourceMap;
12+
13+
return [
14+
{
15+
input: 'src/index.ts',
16+
output: {
17+
format: 'cjs',
18+
file: 'dist/index.cjs',
19+
sourcemap: sourceMap,
20+
exports: 'named'
21+
},
22+
plugins: [
23+
resolve(),
24+
commonjs(),
25+
typescript({
26+
tsconfig: './tsconfig.json',
27+
outDir: 'dist',
28+
sourceMap
29+
})
30+
],
31+
external: ['@powersync/common']
32+
},
33+
// This is required to avoid https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseESM.md
34+
{
35+
input: './lib/index.d.ts',
36+
output: [{ file: 'dist/index.d.cts', format: 'cjs' }],
37+
plugins: [dts()]
38+
}
39+
];
40+
};

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';

0 commit comments

Comments
 (0)