Skip to content

Commit

Permalink
Add mechanism to build for distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
Braden1996 committed Feb 18, 2023
1 parent 68020e0 commit 09e2d19
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ node_modules

# Turborepo
.turbo

# TypeScript
tsconfig.tsbuildinfo
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ Currently, the strategy is to provide an implementation of Replicache's `Experim

Additionally, some configuration is required to received poke events from the server.

## How can I install this?

1. Install the following in your React Native project: `yarn add @react-native-replicache/react-native-quick-sqlite react-native-quick-sqlite expo-crypto`
2. Ensure that you've polyfilled `crypto.getRandomValues` on the global namespace.
- See [here for an example](/~https://github.com/Braden1996/react-native-replicache/blob/master/packages/example/mobile-react-native/src/crypto-polyfill.ts).
3. Pass `createReplicacheQuickSQLiteExperimentalCreateKVStore` into Replicache's `experimentalCreateKVStore` option.
- See [here for an example](/~https://github.com/Braden1996/react-native-replicache/blob/master/packages/example/mobile-react-native/src/use-replicache.ts).

## What else will I need to do?

- Configure a poke mechanism.
- You will likely want to use web-sockets for this, managed via Pusher/Ably/etc
- In our example, [seen here](/~https://github.com/Braden1996/react-native-replicache/blob/master/packages/example/mobile-react-native/src/use-replicache.ts), we use a polyfill for Server Sent Events.
- These aren't built into React Native, but are really handy for a demo.

## How can I experiment with this locally?

### Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion packages/example/client-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test-typescript": "tsc --noEmit",
"lint": "eslint ./src --ext .js,.ts,.tsx",
"lint-fix": "yarn run lint --fix",
"clean": "rm -rf dist .turbo"
"clean": "rm -rf .turbo"
},
"devDependencies": {
"@braden1996/tsconfig": "^0.0.1",
Expand Down
1 change: 0 additions & 1 deletion packages/example/mobile-react-native/tsconfig.tsbuildinfo

This file was deleted.

1 change: 1 addition & 0 deletions packages/example/server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
1 change: 1 addition & 0 deletions packages/react-native-quick-sqlite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
27 changes: 24 additions & 3 deletions packages/react-native-quick-sqlite/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"name": "@react-native-replicache/react-native-quick-sqlite",
"version": "0.0.1",
"main": "./src/index.ts",
"module": "./src/index.ts",
"types": "./src/index.ts",
"main": "./dist/commonjs/index.js",
"module": "./dist/module/index.js",
"react-native": "./src/index.ts",
"types": "./dist/typescript/index.d.ts",
"files": [
"dist/",
"src/"
],
"type": "module",
"repository": {
"type": "git",
Expand All @@ -21,6 +26,7 @@
"url": "/~https://github.com/braden1996/react-native-replicache/issues"
},
"scripts": {
"build": "bob build",
"test": "yarn run test-typescript",
"test-typescript": "tsc --noEmit",
"lint": "eslint ./src --ext .js,.ts,.tsx",
Expand All @@ -33,6 +39,7 @@
"eslint": "8.32.0",
"eslint-config-universe": "^11.1.1",
"prettier": "^2.8.3",
"react-native-builder-bob": "^0.20.3",
"typescript": "~4.9.4"
},
"peerDependencies": {
Expand All @@ -41,6 +48,20 @@
"react-native-quick-sqlite": "8.0.0-beta.2",
"replicache": "12.2.0"
},
"react-native-builder-bob": {
"source": "src",
"output": "dist",
"targets": [
[
"commonjs",
{
"copyFlow": true
}
],
"module",
"typescript"
]
},
"eslintConfig": {
"extends": "universe/native"
}
Expand Down
Loading

0 comments on commit 09e2d19

Please sign in to comment.