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

+9
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

+5
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

+5
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

+1-5
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

-11
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

+1-8
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

+1-7
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

+1-10
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

-1
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

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

demos/example-vite/vite.config.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@ export default defineConfig({
1717
// Don't optimize these packages as they contain web workers and WASM files.
1818
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
1919
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
20-
include: [
21-
'@powersync/web > event-iterator',
22-
'@powersync/web > js-logger',
23-
'@powersync/web > lodash/throttle',
24-
'@powersync/web > can-ndjson-stream',
25-
'@powersync/web > buffer',
26-
'@powersync/web > rsocket-core',
27-
'@powersync/web > rsocket-websocket-client',
28-
'@powersync/web > cross-fetch'
29-
]
20+
include: []
3021
},
3122
plugins: [wasm(), topLevelAwait()],
3223
worker: {

demos/react-multi-client/vite.config.mts

+1-10
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,7 @@ export default defineConfig({
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
wasm(),

demos/react-native-supabase-group-chat/package.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"@tamagui/font-inter": "1.79.6",
3535
"@tamagui/lucide-icons": "1.79.6",
3636
"@tamagui/theme-base": "1.79.6",
37-
"base-64": "^1.0.0",
3837
"date-fns": "^2.30.0",
3938
"expo": "~51.0.10",
4039
"expo-build-properties": "~0.12.1",
@@ -48,19 +47,14 @@
4847
"react": "18.2.0",
4948
"react-dom": "18.2.0",
5049
"react-native": "0.74.1",
51-
"react-native-fetch-api": "^3.0.0",
5250
"react-native-gesture-handler": "~2.16.2",
5351
"react-native-pager-view": "6.3.0",
54-
"react-native-polyfill-globals": "^3.1.0",
5552
"react-native-reanimated": "~3.10.1",
5653
"react-native-safe-area-context": "4.10.1",
5754
"react-native-screens": "~3.31.1",
5855
"react-native-svg": "15.2.0",
59-
"react-native-url-polyfill": "^2.0.0",
6056
"react-native-web": "0.19.12",
61-
"tamagui": "1.79.6",
62-
"text-encoding": "^0.7.0",
63-
"web-streams-polyfill": "3.2.1"
57+
"tamagui": "1.79.6"
6458
},
6559
"devDependencies": {
6660
"@babel/core": "7.24.5",
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
import "react-native-url-polyfill/auto";
2-
import AsyncStorage from "@react-native-async-storage/async-storage";
3-
import { createClient } from "@supabase/supabase-js";
1+
import AsyncStorage from '@react-native-async-storage/async-storage';
2+
import { createClient } from '@supabase/supabase-js';
43

5-
import { config } from "./config";
6-
import { Database } from "./database.types";
4+
import { config } from './config';
5+
import { Database } from './database.types';
76

87
const authStorage = {
9-
setItem: async (key: string, value: string) =>
10-
await AsyncStorage.setItem(key, value),
8+
setItem: async (key: string, value: string) => await AsyncStorage.setItem(key, value),
119
getItem: async (key: string) => await AsyncStorage.getItem(key),
12-
removeItem: async (key: string) => await AsyncStorage.removeItem(key),
10+
removeItem: async (key: string) => await AsyncStorage.removeItem(key)
1311
};
1412

15-
export const supabase = createClient<Database>(
16-
config.supabaseUrl,
17-
config.supabaseAnonKey,
18-
{
19-
auth: {
20-
storage: authStorage,
21-
},
22-
},
23-
);
13+
export const supabase = createClient<Database>(config.supabaseUrl, config.supabaseAnonKey, {
14+
auth: {
15+
storage: authStorage
16+
}
17+
});

demos/react-native-supabase-group-chat/src/providers/PowerSync.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import '@azure/core-asynciterator-polyfill';
2-
import 'react-native-polyfill-globals/auto';
32
import { PowerSyncContext, PowerSyncDatabase } from '@powersync/react-native';
43
import Logger from 'js-logger';
54
import { ReactNode, useMemo } from 'react';

0 commit comments

Comments
 (0)