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

chore: migrate tspc, esbuild to tsup, nx #71

Merged
merged 11 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ dist
cache
temp

*.tsbuildinfo
*.tsbuildinfo


.nx/cache
.nx/workspace-data
4 changes: 2 additions & 2 deletions example/native-method/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@rnx-kit/metro-config": "^1.3.9",
"@webview-bridge/react-native": "workspace:^",
"@webview-bridge/react-native": "1.6.2",
"react": "18.3.1",
"react-native": "0.76.0",
"react-native-inappbrowser-reborn": "^3.7.0",
Expand All @@ -40,7 +40,7 @@
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
"typescript": "^5.6.2"
},
"engines": {
"node": ">=18"
Expand Down
4 changes: 2 additions & 2 deletions example/native-method/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@webview-bridge/web": "workspace:^",
"@webview-bridge/web": "1.6.2",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand All @@ -24,7 +24,7 @@
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.13",
"globals": "^15.11.0",
"typescript": "~5.6.2",
"typescript": "^5.6.2",
"typescript-eslint": "^8.10.0",
"vite": "^5.4.9"
}
Expand Down
4 changes: 2 additions & 2 deletions example/native-method/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"preview": "vite preview"
},
"dependencies": {
"@webview-bridge/web": "workspace:^"
"@webview-bridge/web": "1.6.2"
},
"devDependencies": {
"typescript": "~5.6.2",
"typescript": "^5.6.2",
"vite": "^5.4.9",
"@webview-bridge-example-native-method/react-native": "workspace:^"
}
Expand Down
1 change: 1 addition & 0 deletions example/post-message/react-native/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import InAppBrowser from "react-native-inappbrowser-reborn";

import { z } from "zod";
import * as v from "valibot";

export const appBridge = bridge({
async getMessage() {
return "I'm from native" as const;
Expand Down
4 changes: 2 additions & 2 deletions example/post-message/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@rnx-kit/metro-config": "^1.3.9",
"@webview-bridge/react-native": "workspace:^",
"@webview-bridge/react-native": "1.6.2",
"react": "18.3.1",
"react-native": "0.76.0",
"react-native-inappbrowser-reborn": "^3.7.0",
Expand Down Expand Up @@ -42,7 +42,7 @@
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
"typescript": "^5.6.2"
},
"engines": {
"node": ">=18"
Expand Down
2 changes: 1 addition & 1 deletion example/post-message/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"@webview-bridge/web": "workspace:^"
"@webview-bridge/web": "1.6.2"
},
"devDependencies": {
"@webview-bridge-example-post-message/react-native": "workspace:^",
Expand Down
4 changes: 2 additions & 2 deletions example/react-navigation/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@react-navigation/native": "^6.1.18",
"@react-navigation/native-stack": "^6.11.0",
"@rnx-kit/metro-config": "^1.3.9",
"@webview-bridge/react-native": "workspace:^",
"@webview-bridge/react-native": "1.6.2",
"react": "18.3.1",
"react-native": "0.76.0",
"react-native-inappbrowser-reborn": "^3.7.0",
Expand All @@ -42,7 +42,7 @@
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
"typescript": "^5.6.2"
},
"engines": {
"node": ">=18"
Expand Down
4 changes: 2 additions & 2 deletions example/react-navigation/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"@webview-bridge/web": "workspace:^"
"@webview-bridge/web": "1.6.2"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
Expand All @@ -23,7 +23,7 @@
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.13",
"globals": "^15.11.0",
"typescript": "~5.6.2",
"typescript": "^5.6.2",
"typescript-eslint": "^8.10.0",
"@webview-bridge-example-react-navigation/react-native": "workspace:^",
"vite": "^5.4.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@rnx-kit/metro-config": "^1.3.9",
"@webview-bridge/react-native": "workspace:^",
"@webview-bridge/react-native": "1.6.2",
"react": "18.3.1",
"react-native": "0.76.0",
"react-native-inappbrowser-reborn": "^3.7.0",
Expand All @@ -40,7 +40,7 @@
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
"typescript": "^5.6.2"
},
"engines": {
"node": ">=18"
Expand Down
6 changes: 3 additions & 3 deletions example/shared-state-integration-react/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"preview": "vite preview"
},
"dependencies": {
"@webview-bridge/react": "workspace:^",
"@webview-bridge/web": "workspace:^",
"@webview-bridge/react": "1.6.2",
"@webview-bridge/web": "1.6.2",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand All @@ -24,7 +24,7 @@
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.13",
"globals": "^15.11.0",
"typescript": "~5.6.2",
"typescript": "^5.6.2",
"typescript-eslint": "^8.10.0",
"vite": "^5.4.9",
"@webview-bridge-example-shared-state-integration-react/react-native": "workspace:^"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@rnx-kit/metro-config": "^1.3.9",
"@webview-bridge/react-native": "workspace:^",
"@webview-bridge/react-native": "1.6.2",
"react": "18.3.1",
"react-native": "0.76.0",
"react-native-inappbrowser-reborn": "^3.7.0",
Expand All @@ -40,7 +40,7 @@
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
"typescript": "^5.6.2"
},
"engines": {
"node": ">=18"
Expand Down
4 changes: 2 additions & 2 deletions example/shared-state-integration-vue/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"preview": "vite preview"
},
"dependencies": {
"@webview-bridge/web": "workspace:^",
"@webview-bridge/web": "1.6.2",
"vue": "^3.5.12"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.1.4",
"@webview-bridge-example-shared-state-integration-vue/react-native": "workspace:^",
"typescript": "~5.6.2",
"typescript": "^5.6.2",
"vite": "^5.4.9",
"vue-tsc": "^2.1.6"
}
Expand Down
25 changes: 25 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"targetDefaults": {
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"{projectRoot}/dist"
],
"cache": true
},
"test": {
"dependsOn": [
"^test"
]
},
"test:type": {
"dependsOn": [
"^test:type"
]
}
},
"defaultBase": "main"
}
26 changes: 17 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,37 @@
"main": "index.js",
"scripts": {
"packages:publish": "pnpm clear && pnpm --filter './packages/**' publish",
"build": "pnpm -r build",
"test:type": "pnpm -r test:type",
"docs:build": "pnpm -r docs:build",
"build": "nx run-many --target=build --projects=packages/*",
"test:type": "nx run-many --target=test:type --all",
"docs:build": "nx docs:build @webview-bridge/docs",
"clear": "rimraf --glob **/dist"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@babel/runtime": "^7.20.0",
"@babel/runtime": "^7.25.0",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"esbuild": "^0.19.4",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"ts-patch": "^3.0.2",
"typescript": "^5.2.2",
"typescript-transform-paths": "^3.4.6"
"tsup": "^8.3.0",
"typescript": "^5.6.2",
"nx": "20.0.5"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"pnpm": {
"overrides": {
"@webview-bridge/types": "workspace:*",
"@webview-bridge/utils": "workspace:*",
"@webview-bridge/web": "workspace:*",
"@webview-bridge/react": "workspace:*",
"@webview-bridge/react-native": "workspace:*"
}
}
}
20 changes: 15 additions & 5 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@
"version": "1.6.2",
"type": "module",
"description": "Fully Type-Safe Integration for React Native WebView and Web",
"main": "dist/packages/react-native/src/index.js",
"types": "dist/packages/react-native/src/index.d.ts",
"main": "dist/index.js",
"module": "dist/index.cjs",
"types": "dist/index.d.ts",
"react-native": "src/index.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"publishConfig": {
"access": "public"
},
Expand All @@ -18,22 +27,23 @@
"package.json"
],
"scripts": {
"prepare": "pnpm build",
"build": "tspc",
"build": "tsup src/index.ts --format cjs,esm --dts --target es5",
"test:type": "tsc --noEmit"
},
"devDependencies": {
"@types/react": "^18.2.25",
"@types/use-sync-external-store": "^0.0.6",
"react": "^18.2.0",
"react-native-webview": "^13.12.0",
"typescript": "^5.2.2"
"typescript": "^5.6.2"
},
"peerDependencies": {
"react": "*",
"react-native-webview": "*"
},
"dependencies": {
"@webview-bridge/utils": "1.6.2",
"@webview-bridge/types": "1.6.2",
"use-sync-external-store": "^1.2.0"
}
}
2 changes: 1 addition & 1 deletion packages/react-native/src/createWebView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createEvents } from "@webview-bridge/utils";
import type {
Bridge,
BridgeStore,
Expand All @@ -6,7 +7,6 @@ import type {
ParserSchema,
Primitive,
} from "@webview-bridge/types";
import { createEvents } from "@webview-bridge/util";
import React, {
forwardRef,
useEffect,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export * from "./integrations/bridge";
export * from "./integrations/postMessageSchema";
export * from "./types/webview";
export * from "./useBridge";
export * from "@webview-bridge/types";
export type * from "@webview-bridge/types";
2 changes: 1 addition & 1 deletion packages/react-native/src/integrations/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { equals, removeUndefinedKeys } from "@webview-bridge/utils";
import type {
Bridge,
BridgeStore,
OnlyJSON,
Primitive,
} from "@webview-bridge/types";
import { equals, removeUndefinedKeys } from "@webview-bridge/util";
import WebView from "react-native-webview";

export type StoreCallback<T> = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Bridge } from "@webview-bridge/types";
import type { Bridge } from "@webview-bridge/types";
import {
createRandomId,
createResolver,
type EventEmitter,
timeout,
} from "@webview-bridge/util";
} from "@webview-bridge/utils";
import WebView from "react-native-webview";

import { WebMethodError } from "../error";
Expand Down
5 changes: 2 additions & 3 deletions packages/react-native/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
"forceConsistentCasingInFileNames": true,
"jsx": "react-native",
"lib": ["esnext"],
"module": "CommonJS",

"moduleResolution": "node",
"module": "esnext",
"moduleResolution": "Bundler",
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
Expand Down
Loading
Loading