-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cc53cd
commit c82ae7c
Showing
4 changed files
with
28 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,23 @@ | ||
# Typescript + React | ||
# Summary | ||
This is an example code to use `clvm-js` with typescript and react with vite. | ||
|
||
## Setup | ||
```shell | ||
yarn | ||
yarn build | ||
# or | ||
npm install | ||
npm run build | ||
``` | ||
# Setup | ||
|
||
## Start web page | ||
```shell | ||
yarn start | ||
# or | ||
npm run start | ||
``` | ||
# 0. Install pnpm (yarn is also OK) | ||
# 1. Clone this repository | ||
git clone https://github.com/Chia-Mine/clvm-js | ||
cd clvm-js | ||
|
||
## Memo - How to set up react+typescript project from scratch | ||
```shell | ||
npx create-react-app some-project --template typescript | ||
cd some-project | ||
yarn add clvm_tools | ||
``` | ||
Then copy wasm files from npm package. | ||
```shell | ||
mkdir -p ./public/static/js | ||
cp ./node_modules/clvm_tools/browser/*.wasm ./public/static/js/ | ||
``` | ||
**Note**: Redistributing your project with bundled `blsjs.wasm` and/or `clvm_rs_bg.wasm` must be compliant with Apache2.0 License provided by [Chia-Network](https://github.com/Chia-Network/) | ||
# 2. Build clvm-js | ||
pnpm i # or `yarn`, `npm i` | ||
pnpm build # or `yarn build`, `npm run build` | ||
|
||
# 3. Build example code for web browsers | ||
cd example/typescript_react | ||
pnpm i # or `yarn`, `npm i` | ||
pnpm build # or `yarn build`, `npm run build` | ||
|
||
Additionally, copy and paste below to package.json. | ||
This prevents `babel` in `react-scripts` from applying [the problematic transform](https://github.com/facebook/create-react-app/issues/10785). | ||
# 4. Run demo server | ||
pnpm start # or `yarn start`, `npm start` | ||
``` | ||
"browserslist": [ | ||
"edge >= 79", | ||
"firefox >= 68", | ||
"chrome >= 67", | ||
"safari > 14", | ||
"opera >= 54", | ||
"ios_saf >= 14.4", | ||
"android >= 67", | ||
"op_mob >= 48", | ||
"and_chr >= 67", | ||
"and_ff >= 68", | ||
"samsung >= 9.2", | ||
"node >= 10.4.0", | ||
"electron >= 4.0.0" | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters