Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/nasty-pugs-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'@powersync/tanstack-react-query': patch
'@powersync/op-sqlite': patch
'@powersync/adapter-sql-js': patch
'@powersync/drizzle-driver': patch
'@powersync/kysely-driver': patch
'@powersync/react-native': patch
'@powersync/diagnostics-app': patch
'@powersync/attachments': patch
'@powersync/capacitor': patch
'@powersync/common': patch
'@powersync/react': patch
'@powersync/node': patch
'@powersync/vue': patch
'@powersync/web': patch
---

Don't minify releases, enable source maps.
3 changes: 2 additions & 1 deletion demos/example-electron-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ To see it in action:
1. Make sure to run `pnpm install` and `pnpm build:packages` in the root directory of this repo.
2. Copy `.env.local.template` to `.env.local`, and complete the environment variables. You can generate a [temporary development token](https://docs.powersync.com/usage/installation/authentication-setup/development-tokens), or leave blank to test with local-only data.
The example works with the schema from the [PowerSync + Supabase tutorial](https://docs.powersync.com/integration-guides/supabase-+-powersync#supabase-powersync).
3. `cd` into this directory. In this mono-repo, you'll have to run `./node_modules/.bin/electron-rebuild` once to make sure `@powersync/better-sqlite3` was compiled with Electron's toolchain.
3. `cd` into this directory. In this mono-repo, you'll have to run `./node_modules/.bin/electron-rebuild` once to make sure `better-sqlite3` was compiled with Electron's toolchain.
Sometimes that doesn't work, you can also go to `node_modules/better-sqlite3` and manually run `HOME=~/.electron-gyp node-gyp rebuild --target=37.0.0 --arch=arm64 --dist-url=https://electronjs.org/headers` (or `--arch=x64` depending on your machine).
4. Finally, run `pnpm start`.

Apart from the build setup, this example is purposefully kept simple.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import '@azure/core-asynciterator-polyfill';

import React from 'react';
import { LogLevel, PowerSyncDatabase as PowerSyncDatabaseNative } from '@powersync/react-native';
import { PowerSyncDatabase as PowerSyncDatabaseNative } from '@powersync/react-native';
import { PowerSyncDatabase as PowerSyncDatabaseWeb, WASQLiteOpenFactory } from '@powersync/web';
import { AbstractPowerSyncDatabase, createBaseLogger } from '@powersync/common';
import { LogLevel, AbstractPowerSyncDatabase, createBaseLogger } from '@powersync/common';
import { SupabaseStorageAdapter } from '../storage/SupabaseStorageAdapter';
import { type AttachmentRecord } from '@powersync/attachments';
import { KVStorage } from '../storage/KVStorage';
Expand Down
7 changes: 4 additions & 3 deletions packages/adapter-sql-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"license": "Apache-2.0",
"files": [
"lib",
"dist"
"dist",
"src"
],
"repository": {
"type": "git",
Expand All @@ -26,13 +27,13 @@
"homepage": "https://docs.powersync.com",
"scripts": {
"build": "tsc -b && rollup -c rollup.config.mjs",
"build:prod": "tsc -b --sourceMap false && rollup -c rollup.config.mjs --sourceMap false",
"build:prod": "tsc -b && rollup -c rollup.config.mjs",
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
"test": "vitest"
},
"dependencies": {
"@powersync/common": "workspace:^",
"async-mutex": "^0.4.0"
"async-mutex": "^0.5.0"
},
"devDependencies": {
"@powersync/sql-js": "0.0.5",
Expand Down
11 changes: 3 additions & 8 deletions packages/adapter-sql-js/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ const __dirname = path.dirname(__filename);
/**
* @returns {import('rollup').RollupOptions}
*/
export default (commandLineArgs) => {
const sourceMap = (commandLineArgs.sourceMap || 'true') == 'true';

// Clears rollup CLI warning https://github.com/rollup/rollup/issues/2694
delete commandLineArgs.sourceMap;

export default () => {
return {
input: 'lib/index.js',
output: {
file: 'dist/bundle.mjs',
format: 'esm',
sourcemap: sourceMap
sourcemap: true
},
plugins: [
nodeResolve({ preferBuiltins: false, browser: true }),
Expand All @@ -36,6 +31,6 @@ export default (commandLineArgs) => {
]
})
],
external: ['@powersync/common']
external: ['@powersync/common', 'async-mutex']
};
};
5 changes: 3 additions & 2 deletions packages/attachments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
},
"files": [
"lib",
"dist"
"dist",
"src"
],
"scripts": {
"build": "tsc -b && rollup --config",
"build:prod": "tsc -b --sourceMap false && rollup --config --sourceMap=false",
"build:prod": "tsc -b --sourceMap false && rollup",
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
"watch": "tsc -b -w",
"test": "pnpm build && vitest",
Expand Down
11 changes: 3 additions & 8 deletions packages/attachments/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ import typescript from '@rollup/plugin-typescript';
import { dts } from 'rollup-plugin-dts';

/** @type {import('rollup').RollupOptions} */
export default (commandLineArgs) => {
const sourceMap = (commandLineArgs.sourceMap || 'true') == 'true';

// Clears rollup CLI warning https://github.com/rollup/rollup/issues/2694
delete commandLineArgs.sourceMap;

export default () => {
return [
{
input: 'src/index.ts',
output: {
format: 'cjs',
file: 'dist/index.cjs',
sourcemap: sourceMap,
sourcemap: true,
exports: 'named'
},
plugins: [
Expand All @@ -25,7 +20,7 @@ export default (commandLineArgs) => {
typescript({
tsconfig: './tsconfig.json',
outDir: 'dist',
sourceMap
sourceMap: true
})
],
external: ['@powersync/common']
Expand Down
1 change: 1 addition & 0 deletions packages/capacitor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"android/build.gradle",
"android/proguard-rules.pro",
"dist/",
"src",
"ios/Sources",
"ios/Tests",
"Package.swift",
Expand Down
36 changes: 22 additions & 14 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
"types": "lib/index.d.ts",
"exports": {
".": {
"node": {
"import": {
"types": "./lib/index.d.ts",
"default": "./dist/bundle.node.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"require": "./dist/bundle.node.cjs"
}
},
"import": {
"types": "./lib/index.d.ts",
"default": "./dist/bundle.mjs"
Expand All @@ -26,7 +36,8 @@
"license": "Apache-2.0",
"files": [
"lib",
"dist"
"dist",
"src"
],
"repository": {
"type": "git",
Expand All @@ -38,31 +49,28 @@
"homepage": "https://docs.powersync.com",
"scripts": {
"build": "tsc -b && rollup -c rollup.config.mjs",
"build:prod": "tsc -b --sourceMap false && rollup -c rollup.config.mjs --sourceMap false",
"build:prod": "tsc -b && rollup -c rollup.config.mjs",
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
"test": "vitest",
"test:exports": "attw --pack ."
},
"dependencies": {
"js-logger": "^1.6.1"
"async-mutex": "^0.5.0",
"buffer": "^6.0.3",
"event-iterator": "^2.0.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-node-resolve": "^16.0.3",
"@types/node": "^20.5.9",
"@types/uuid": "^9.0.1",
"async-mutex": "^0.4.0",
"bson": "^6.6.0",
"buffer": "^6.0.3",
"cross-fetch": "^4.0.0",
"event-iterator": "^2.0.0",
"rollup": "4.14.3",
"rollup": "^4.52.5",
"cross-fetch": "^4.1.0",
"js-logger": "^1.6.1",
"rsocket-core": "1.0.0-alpha.3",
"rsocket-websocket-client": "1.0.0-alpha.3",
"text-encoding": "^0.7.0",
"web-streams-polyfill": "3.2.1"
"bson": "^6.10.4"
}
}
71 changes: 34 additions & 37 deletions packages/common/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
import * as path from 'node:path';

import commonjs from '@rollup/plugin-commonjs';
import inject from '@rollup/plugin-inject';
import json from '@rollup/plugin-json';
import nodeResolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import { dts } from 'rollup-plugin-dts';

/**
* @returns {import('rollup').RollupOptions}
*/
export default (commandLineArgs) => {
const sourceMap = (commandLineArgs.sourceMap || 'true') == 'true';

// Clears rollup CLI warning https://github.com/rollup/rollup/issues/2694
delete commandLineArgs.sourceMap;
function defineBuild(isNode) {
const suffix = isNode ? '.node' : '';

return [
{
input: 'lib/index.js',
output: [
{
file: 'dist/bundle.mjs',
format: 'esm',
sourcemap: sourceMap
},
{
file: 'dist/bundle.cjs',
format: 'cjs',
sourcemap: sourceMap
}
],
plugins: [
return {
input: 'lib/index.js',
output: [
{
file: `dist/bundle${suffix}.mjs`,
format: 'esm',
sourcemap: true
},
{
file: `dist/bundle${suffix}.cjs`,
format: 'cjs',
sourcemap: true
}
],
plugins: [
[
json(),
nodeResolve({ preferBuiltins: false, browser: true }),
commonjs({}),
inject({
Buffer: ['buffer', 'Buffer'],
ReadableStream: ['web-streams-polyfill/ponyfill', 'ReadableStream'],
// Used by can-ndjson-stream
TextDecoder: ['text-encoding', 'TextDecoder']
}),
terser({ sourceMap })
],
// This makes life easier
external: [
// This has dynamic logic - makes bundling hard
'cross-fetch'
Buffer: isNode ? ['node:buffer', 'Buffer'] : ['buffer/', 'Buffer']
})
]
},
],
external: ['async-mutex', 'bson', 'buffer/', 'event-iterator']
};
}

/**
* @returns {import('rollup').RollupOptions}
*/
export default () => {
return [
defineBuild(false),
defineBuild(true),
{
input: './lib/index.d.ts',
output: [{ file: 'dist/index.d.cts', format: 'cjs' }],
Expand Down
11 changes: 9 additions & 2 deletions packages/common/src/client/sync/stream/AbstractRemote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { BSON } from 'bson';
import { Buffer } from 'buffer';
import { type fetch } from 'cross-fetch';
import Logger, { ILogger } from 'js-logger';
import { RSocket, RSocketConnector, Requestable } from 'rsocket-core';
Expand Down Expand Up @@ -263,6 +262,14 @@ export abstract class AbstractRemote {
*/
abstract getBSON(): Promise<BSONImplementation>;

/**
* @returns A text decoder decoding UTF-8. This is a method to allow patching it for Hermes which doesn't support the
* builtin, without forcing us to bundle a polyfill with `@powersync/common`.
*/
protected createTextDecoder(): TextDecoder {
return new TextDecoder();
}

protected createSocket(url: string): WebSocket {
return new WebSocket(url);
}
Expand Down Expand Up @@ -564,7 +571,7 @@ export abstract class AbstractRemote {
closeReader();
});

const decoder = new TextDecoder();
const decoder = this.createTextDecoder();
let buffer = '';

const stream = new DataStream<T, string>({
Expand Down
5 changes: 3 additions & 2 deletions packages/drizzle-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"license": "Apache-2.0",
"files": [
"lib",
"dist"
"dist",
"src"
],
"repository": "https://github.com/powersync-ja/powersync-js",
"bugs": {
Expand All @@ -35,7 +36,7 @@
"homepage": "https://docs.powersync.com",
"scripts": {
"build": "tsc -b && rollup --config",
"build:prod": "tsc -b --sourceMap false && rollup --config --sourceMap=false",
"build:prod": "tsc -b && rollup --config",
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
"watch": "tsc --build -w",
"test": "vitest",
Expand Down
5 changes: 3 additions & 2 deletions packages/kysely-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"license": "Apache-2.0",
"files": [
"lib",
"dist"
"dist",
"src"
],
"repository": "https://github.com/powersync-ja/powersync-js",
"bugs": {
Expand All @@ -35,7 +36,7 @@
"homepage": "https://docs.powersync.com",
"scripts": {
"build": "tsc -b && rollup --config",
"build:prod": "tsc -b --sourceMap false && rollup --config --sourceMap=false",
"build:prod": "tsc -b && rollup --config",
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
"watch": "tsc --build -w",
"test": "pnpm build && vitest",
Expand Down
Loading