Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[polyfills] Bundling of package dependencies #237

Merged
merged 31 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
44d7247
test
stevensJourney Jun 3, 2024
6b5ced4
not working state webpack config for react native bundling
Chriztiaan Jun 25, 2024
a24fba5
Testing dev publish
Chriztiaan Jul 1, 2024
f752719
Merge branch 'main' into poc-bundle-christiaan
Chriztiaan Jul 2, 2024
0638cc2
Dropping unused dependencies.
Chriztiaan Jul 2, 2024
0057d8e
Cleaned react-native package.json.
Chriztiaan Jul 3, 2024
f6a451f
Bson alias.
Chriztiaan Jul 4, 2024
1974635
Resolved readable stream polyfill.
Chriztiaan Jul 4, 2024
27fd57c
PoC of prebundling (half working React Native and half working common).
Chriztiaan Jul 9, 2024
04e35c1
fix React navtive
stevensJourney Jul 10, 2024
d856e91
random cleanup
stevensJourney Jul 10, 2024
d749c68
Common changeset.
Chriztiaan Jul 12, 2024
e410da0
Testing inline vite webworker syntax.
Chriztiaan Jul 12, 2024
a2cac24
Testing rollup common with tsc web.
Chriztiaan Jul 15, 2024
cfc5054
Dropped buffer from `web`.
Chriztiaan Jul 15, 2024
dd06141
Dropped default implementation of fetch (via cross-fetch) in common.
Chriztiaan Jul 16, 2024
7d8ab8c
Merge branch 'main' into poc-bundle-christiaan-steven
Chriztiaan Jul 16, 2024
c84ac1c
Fixed web-streams-polyfills using a polyfill instead of a ponyfill (b…
Chriztiaan Jul 17, 2024
d9ccb77
Started updating dependencies and polyfills.
Chriztiaan Jul 17, 2024
58dbde7
Fix ponyfills + Merge branch 'main' into poc-bundle-christiaan-steven
Chriztiaan Jul 17, 2024
e5ea43b
Updating todo apps. Removed code/dependencies related to polyfllls .
Chriztiaan Jul 18, 2024
9440b7b
Changelog entries. Used for dev package release.
Chriztiaan Jul 19, 2024
0bc04e0
Merge branch 'main' into poc-bundle-christiaan-steven
Chriztiaan Jul 19, 2024
1f683c0
Updated demo vite config to have an empty include.
Chriztiaan Jul 22, 2024
c87b59c
Merge branch 'main' into poc-bundle-christiaan-steven
Chriztiaan Jul 22, 2024
5a3e2aa
Added web to changesets.
Chriztiaan Jul 22, 2024
fd869fd
Vendoring crypto.
Chriztiaan Jul 22, 2024
5db3507
Cleanup react-supabase-todolist vite config.
Chriztiaan Jul 22, 2024
047c141
Updated changesets to be minor instead of patch.
Chriztiaan Jul 23, 2024
5e03971
Minified bundles for common and react-native.
Chriztiaan Jul 23, 2024
5642b97
Merge branch 'main' into prebundling
Chriztiaan Jul 29, 2024
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
9 changes: 9 additions & 0 deletions .changeset/brave-owls-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@powersync/attachments': minor
'@powersync/kysely-driver': minor
'@powersync/react': minor
'@powersync/vue': minor
'@powersync/web': minor
---

Prebundling dependencies with the aim of reducing the need for polyfills.
5 changes: 5 additions & 0 deletions .changeset/many-clouds-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/react-native': minor
---

Prebundling react-native dependencies with the aim of reducing the need for polyfills.
5 changes: 5 additions & 0 deletions .changeset/nasty-timers-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/common': minor
---

Prebundling common package with the aim of reducing the need for polyfills.
6 changes: 1 addition & 5 deletions demos/angular-supabase-todolist/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
"path": "./extra-webpack.config.js"
},
"allowedCommonJsDependencies": [
"object-hash",
"event-iterator",
"can-ndjson-stream",
"lodash",
"js-logger",
"websocket"
"ws"
],
"outputPath": "dist",
"index": "src/index.html",
Expand Down
11 changes: 0 additions & 11 deletions demos/django-react-native-todolist/library/stores/system.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import '@azure/core-asynciterator-polyfill';
import 'react-native-polyfill-globals/auto';
import React from 'react';
import { AbstractPowerSyncDatabase, PowerSyncDatabase, SyncStreamConnectionMethod } from '@powersync/react-native';
import { Buffer } from '@craftzdog/react-native-buffer';
import { AppSchema } from '../powersync/AppSchema';
import { DjangoConnector } from '../django/DjangoConnector';

if (typeof process.nextTick == 'undefined') {
process.nextTick = setImmediate;
}

if (typeof global.Buffer == 'undefined') {
// @ts-ignore
global.Buffer = Buffer;
}

export class System {
djangoConnector: DjangoConnector;
powersync: AbstractPowerSyncDatabase;
Expand Down
9 changes: 1 addition & 8 deletions demos/django-react-native-todolist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"dependencies": {
"@azure/core-asynciterator-polyfill": "^1.0.2",
"@craftzdog/react-native-buffer": "^6.0.5",
"@expo/vector-icons": "^14.0.0",
"@journeyapps/react-native-quick-sqlite": "^1.1.7",
"@powersync/common": "workspace:*",
Expand All @@ -20,7 +19,6 @@
"@react-navigation/drawer": "^6.6.15",
"@react-navigation/native": "^6.1.17",
"@supabase/supabase-js": "^2.42.4",
"base-64": "^1.0.0",
"expo": "~51.0.10",
"expo-build-properties": "~0.12.1",
"expo-constants": "~16.0.2",
Expand All @@ -36,21 +34,16 @@
"react-native": "0.74.1",
"react-native-elements": "^3.4.3",
"react-native-encrypted-storage": "^4.0.3",
"react-native-fetch-api": "^3.0.0",
"react-native-gesture-handler": "~2.16.2",
"react-native-polyfill-globals": "^3.1.0",
"react-native-prompt-android": "^1.1.0",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.1",
"react-native-safe-area-view": "^1.1.1",
"react-native-screens": "~3.31.1",
"react-native-table-component": "^1.2.2",
"react-native-url-polyfill": "^2.0.0",
"react-native-vector-icons": "^10.0.0",
"react-navigation-stack": "^2.10.4",
"text-encoding": "^0.7.0",
"typed-async-storage": "^3.1.2",
"web-streams-polyfill": "^3.3.3"
"typed-async-storage": "^3.1.2"
},
"devDependencies": {
"@babel/plugin-transform-async-generator-functions": "^7.24.3",
Expand Down
8 changes: 1 addition & 7 deletions demos/example-capacitor/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ export default defineConfig({
// Don't optimize these packages as they contain web workers and WASM files.
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
include: [
'@powersync/web > uuid',
'@powersync/web > event-iterator',
'@powersync/web > js-logger',
'@powersync/web > lodash/throttle',
'@powersync/web > can-ndjson-stream'
]
include: []
Copy link
Contributor Author

@Chriztiaan Chriztiaan Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By having an empty array instead of omitting the field, it silences a vite warning.

},
plugins: [wasm(), topLevelAwait()],
worker: {
Expand Down
11 changes: 1 addition & 10 deletions demos/example-electron/vite.renderer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,7 @@ export default defineConfig((env) => {
// Don't optimize these packages as they contain web workers and WASM files.
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
include: [
'@powersync/web > event-iterator',
'@powersync/web > js-logger',
'@powersync/web > lodash/throttle',
'@powersync/web > can-ndjson-stream',
'@powersync/web > buffer',
'@powersync/web > rsocket-core',
'@powersync/web > rsocket-websocket-client',
'@powersync/web > cross-fetch'
]
include: []
},
plugins: [
// @ts-expect-error there is TS issue that doesn't actually affect the runtime
Expand Down
1 change: 0 additions & 1 deletion demos/example-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@mui/material": "^5.15.18",
"@powersync/react": "workspace:*",
"@powersync/web": "workspace:*",
"buffer": "^6.0.3",
"js-logger": "^1.6.1",
"lato-font": "^3.0.0",
"lexical": "^0.15.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import { CircularProgress } from '@mui/material';
import Logger from 'js-logger';
import React, { Suspense } from 'react';

import { Buffer } from 'buffer';

// Polyfill for WebSockets
if (typeof self.Buffer == 'undefined') {
self.Buffer = Buffer;
}

// eslint-disable-next-line react-hooks/rules-of-hooks
Logger.useDefaults();
Logger.setLevel(Logger.DEBUG);
Expand Down
11 changes: 1 addition & 10 deletions demos/example-vite/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ export default defineConfig({
// Don't optimize these packages as they contain web workers and WASM files.
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
include: [
'@powersync/web > event-iterator',
'@powersync/web > js-logger',
'@powersync/web > lodash/throttle',
'@powersync/web > can-ndjson-stream',
'@powersync/web > buffer',
'@powersync/web > rsocket-core',
'@powersync/web > rsocket-websocket-client',
'@powersync/web > cross-fetch'
]
include: []
},
plugins: [wasm(), topLevelAwait()],
worker: {
Expand Down
11 changes: 1 addition & 10 deletions demos/react-multi-client/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,7 @@ export default defineConfig({
// Don't optimize these packages as they contain web workers and WASM files.
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
include: [
'@powersync/web > event-iterator',
'@powersync/web > js-logger',
'@powersync/web > lodash/throttle',
'@powersync/web > can-ndjson-stream',
'@powersync/web > buffer',
'@powersync/web > rsocket-core',
'@powersync/web > rsocket-websocket-client',
'@powersync/web > cross-fetch'
]
include: []
},
plugins: [
wasm(),
Expand Down
8 changes: 1 addition & 7 deletions demos/react-native-supabase-group-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@tamagui/font-inter": "1.79.6",
"@tamagui/lucide-icons": "1.79.6",
"@tamagui/theme-base": "1.79.6",
"base-64": "^1.0.0",
"date-fns": "^2.30.0",
"expo": "~51.0.10",
"expo-build-properties": "~0.12.1",
Expand All @@ -48,19 +47,14 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.1",
"react-native-fetch-api": "^3.0.0",
"react-native-gesture-handler": "~2.16.2",
"react-native-pager-view": "6.3.0",
"react-native-polyfill-globals": "^3.1.0",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.1",
"react-native-screens": "~3.31.1",
"react-native-svg": "15.2.0",
"react-native-url-polyfill": "^2.0.0",
"react-native-web": "0.19.12",
"tamagui": "1.79.6",
"text-encoding": "^0.7.0",
"web-streams-polyfill": "3.2.1"
"tamagui": "1.79.6"
},
"devDependencies": {
"@babel/core": "7.24.5",
Expand Down
28 changes: 11 additions & 17 deletions demos/react-native-supabase-group-chat/src/lib/supabase.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import "react-native-url-polyfill/auto";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { createClient } from "@supabase/supabase-js";
import AsyncStorage from '@react-native-async-storage/async-storage';
import { createClient } from '@supabase/supabase-js';

import { config } from "./config";
import { Database } from "./database.types";
import { config } from './config';
import { Database } from './database.types';

const authStorage = {
setItem: async (key: string, value: string) =>
await AsyncStorage.setItem(key, value),
setItem: async (key: string, value: string) => await AsyncStorage.setItem(key, value),
getItem: async (key: string) => await AsyncStorage.getItem(key),
removeItem: async (key: string) => await AsyncStorage.removeItem(key),
removeItem: async (key: string) => await AsyncStorage.removeItem(key)
};

export const supabase = createClient<Database>(
config.supabaseUrl,
config.supabaseAnonKey,
{
auth: {
storage: authStorage,
},
},
);
export const supabase = createClient<Database>(config.supabaseUrl, config.supabaseAnonKey, {
auth: {
storage: authStorage
}
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import '@azure/core-asynciterator-polyfill';
import 'react-native-polyfill-globals/auto';
import { PowerSyncContext, PowerSyncDatabase } from '@powersync/react-native';
import Logger from 'js-logger';
import { ReactNode, useMemo } from 'react';
Expand Down
Loading
Loading