Skip to content

Commit 02ae5de

Browse files
[polyfills] Bundling of package dependencies (#237)
Co-authored-by: Steven Ontong <[email protected]>
1 parent b0b31ac commit 02ae5de

File tree

40 files changed

+16582
-21548
lines changed

40 files changed

+16582
-21548
lines changed

.changeset/brave-owls-tease.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@powersync/attachments': minor
3+
'@powersync/kysely-driver': minor
4+
'@powersync/react': minor
5+
'@powersync/vue': minor
6+
'@powersync/web': minor
7+
---
8+
9+
Prebundling dependencies with the aim of reducing the need for polyfills.

.changeset/many-clouds-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/react-native': minor
3+
---
4+
5+
Prebundling react-native dependencies with the aim of reducing the need for polyfills.

.changeset/nasty-timers-push.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/common': minor
3+
---
4+
5+
Prebundling common package with the aim of reducing the need for polyfills.

demos/angular-supabase-todolist/angular.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@
2121
"path": "./extra-webpack.config.js"
2222
},
2323
"allowedCommonJsDependencies": [
24-
"object-hash",
25-
"event-iterator",
26-
"can-ndjson-stream",
27-
"lodash",
2824
"js-logger",
29-
"websocket"
25+
"ws"
3026
],
3127
"outputPath": "dist",
3228
"index": "src/index.html",

demos/django-react-native-todolist/library/stores/system.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
import '@azure/core-asynciterator-polyfill';
2-
import 'react-native-polyfill-globals/auto';
32
import React from 'react';
43
import { AbstractPowerSyncDatabase, PowerSyncDatabase, SyncStreamConnectionMethod } from '@powersync/react-native';
5-
import { Buffer } from '@craftzdog/react-native-buffer';
64
import { AppSchema } from '../powersync/AppSchema';
75
import { DjangoConnector } from '../django/DjangoConnector';
86

9-
if (typeof process.nextTick == 'undefined') {
10-
process.nextTick = setImmediate;
11-
}
12-
13-
if (typeof global.Buffer == 'undefined') {
14-
// @ts-ignore
15-
global.Buffer = Buffer;
16-
}
17-
187
export class System {
198
djangoConnector: DjangoConnector;
209
powersync: AbstractPowerSyncDatabase;

demos/django-react-native-todolist/package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
},
1010
"dependencies": {
1111
"@azure/core-asynciterator-polyfill": "^1.0.2",
12-
"@craftzdog/react-native-buffer": "^6.0.5",
1312
"@expo/vector-icons": "^14.0.0",
1413
"@journeyapps/react-native-quick-sqlite": "^1.1.7",
1514
"@powersync/common": "workspace:*",
@@ -20,7 +19,6 @@
2019
"@react-navigation/drawer": "^6.6.15",
2120
"@react-navigation/native": "^6.1.17",
2221
"@supabase/supabase-js": "^2.42.4",
23-
"base-64": "^1.0.0",
2422
"expo": "~51.0.10",
2523
"expo-build-properties": "~0.12.1",
2624
"expo-constants": "~16.0.2",
@@ -36,21 +34,16 @@
3634
"react-native": "0.74.1",
3735
"react-native-elements": "^3.4.3",
3836
"react-native-encrypted-storage": "^4.0.3",
39-
"react-native-fetch-api": "^3.0.0",
4037
"react-native-gesture-handler": "~2.16.2",
41-
"react-native-polyfill-globals": "^3.1.0",
4238
"react-native-prompt-android": "^1.1.0",
4339
"react-native-reanimated": "~3.10.1",
4440
"react-native-safe-area-context": "4.10.1",
4541
"react-native-safe-area-view": "^1.1.1",
4642
"react-native-screens": "~3.31.1",
4743
"react-native-table-component": "^1.2.2",
48-
"react-native-url-polyfill": "^2.0.0",
4944
"react-native-vector-icons": "^10.0.0",
5045
"react-navigation-stack": "^2.10.4",
51-
"text-encoding": "^0.7.0",
52-
"typed-async-storage": "^3.1.2",
53-
"web-streams-polyfill": "^3.3.3"
46+
"typed-async-storage": "^3.1.2"
5447
},
5548
"devDependencies": {
5649
"@babel/plugin-transform-async-generator-functions": "^7.24.3",

demos/example-capacitor/vite.config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ export default defineConfig({
1818
// Don't optimize these packages as they contain web workers and WASM files.
1919
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
2020
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
21-
include: [
22-
'@powersync/web > uuid',
23-
'@powersync/web > event-iterator',
24-
'@powersync/web > js-logger',
25-
'@powersync/web > lodash/throttle',
26-
'@powersync/web > can-ndjson-stream'
27-
]
21+
include: []
2822
},
2923
plugins: [wasm(), topLevelAwait()],
3024
worker: {

demos/example-electron/vite.renderer.config.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,7 @@ export default defineConfig((env) => {
2525
// Don't optimize these packages as they contain web workers and WASM files.
2626
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
2727
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
28-
include: [
29-
'@powersync/web > event-iterator',
30-
'@powersync/web > js-logger',
31-
'@powersync/web > lodash/throttle',
32-
'@powersync/web > can-ndjson-stream',
33-
'@powersync/web > buffer',
34-
'@powersync/web > rsocket-core',
35-
'@powersync/web > rsocket-websocket-client',
36-
'@powersync/web > cross-fetch'
37-
]
28+
include: []
3829
},
3930
plugins: [
4031
// @ts-expect-error there is TS issue that doesn't actually affect the runtime

demos/example-nextjs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"@mui/material": "^5.15.18",
2020
"@powersync/react": "workspace:*",
2121
"@powersync/web": "workspace:*",
22-
"buffer": "^6.0.3",
2322
"js-logger": "^1.6.1",
2423
"lato-font": "^3.0.0",
2524
"lexical": "^0.15.0",

demos/example-nextjs/src/components/providers/SystemProvider.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ import { CircularProgress } from '@mui/material';
88
import Logger from 'js-logger';
99
import React, { Suspense } from 'react';
1010

11-
import { Buffer } from 'buffer';
12-
13-
// Polyfill for WebSockets
14-
if (typeof self.Buffer == 'undefined') {
15-
self.Buffer = Buffer;
16-
}
17-
1811
// eslint-disable-next-line react-hooks/rules-of-hooks
1912
Logger.useDefaults();
2013
Logger.setLevel(Logger.DEBUG);

0 commit comments

Comments
 (0)