Skip to content

Commit

Permalink
WIP: Fix rollup config by adding nodePolyfills()
Browse files Browse the repository at this point in the history
  • Loading branch information
mugikhan committed Oct 7, 2024
1 parent ad2e65e commit 28902d5
Show file tree
Hide file tree
Showing 4 changed files with 2,203 additions and 321 deletions.
3 changes: 1 addition & 2 deletions demos/react-native-supabase-todolist/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../../node_modules/expo/tsconfig.base.json",
"compilerOptions": {
"strict": true,
"composite": true,
"moduleResolution": "Bundler"
"composite": true
}
}
2 changes: 2 additions & 0 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"description": "PowerSync - sync Postgres with SQLite in your React Native app for offline-first and real-time data",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./lib/index.d.ts",
"files": [
"lib",
Expand Down Expand Up @@ -60,6 +61,7 @@
"react-native": "0.72.4",
"react-native-fetch-api": "^3.0.0",
"rollup": "4.14.3",
"rollup-plugin-node-polyfills": "^0.2.1",
"text-encoding": "^0.7.0",
"typescript": "^5.5.3",
"web-streams-polyfill": "3.2.1"
Expand Down
16 changes: 10 additions & 6 deletions packages/react-native/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import replace from '@rollup/plugin-replace';
import path from 'path';
import { fileURLToPath } from 'url';
import terser from '@rollup/plugin-terser';
import nodePolyfills from 'rollup-plugin-node-polyfills';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand All @@ -31,6 +32,10 @@ export default (commandLineArgs) => {
delimiters: ['', ''],
preventAssignment: true
}),
nodePolyfills(),
nodeResolve({
preferBuiltins: false,
}),
json(),
commonjs({}),
inject({
Expand All @@ -41,12 +46,11 @@ export default (commandLineArgs) => {
// injecting our crypto implementation
crypto: path.resolve('./vendor/crypto.js')
}),
// alias({
// entries: [
// { find: 'bson', replacement: path.resolve(__dirname, '../../node_modules/bson/lib/bson.rn.cjs') },
// // { find: '@journeyapps/react-native-quick-sqlite', replacement: path.resolve(__dirname, '../../node_modules/@journeyapps/react-native-quick-sqlite/lib/commonjs/index.js') },
// ]
// }),
alias({
entries: [
{ find: 'bson', replacement: path.resolve(__dirname, '../../node_modules/bson/lib/bson.rn.cjs') },
]
}),
terser()
],
external: [
Expand Down
Loading

0 comments on commit 28902d5

Please sign in to comment.