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

[Feature] Improve HMR and build performance of aleo.tools #618

Merged
merged 25 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0fce70b
first pass
onetrickwolf May 12, 2023
15041ac
reformat
onetrickwolf May 12, 2023
19afcb4
rest call version
onetrickwolf May 12, 2023
c4716ed
rest call version tuning
onetrickwolf May 12, 2023
a9f1d1a
formatting
onetrickwolf May 12, 2023
face576
Merge branch 'testnet3' of https://github.com/AleoHQ/sdk into brent-test
onetrickwolf Jun 19, 2023
2bc5af0
initial vite
onetrickwolf Jun 20, 2023
1b89229
Working vite + swc
onetrickwolf Jun 21, 2023
6385831
Removing code from other issue
onetrickwolf Jun 21, 2023
e700bc8
using webpack for build due to vite bug\
onetrickwolf Jun 24, 2023
ff3e36b
moving swc to main website directory
onetrickwolf Jun 24, 2023
d8beabe
Merge branch 'testnet3' of https://github.com/AleoHQ/sdk into feat/we…
onetrickwolf Jun 24, 2023
6645cf3
Reorder version in package.json and remove redundant index.html
onetrickwolf Jun 24, 2023
fc4e8dc
fixing keys extension for new build system
onetrickwolf Jun 24, 2023
26f9b1b
change path for index.html in webpack config
onetrickwolf Jun 24, 2023
702c371
documentation update
onetrickwolf Jun 26, 2023
b707bde
patching wasm-bindgen-rayon for vite workaround, removing webpack
onetrickwolf Jun 29, 2023
d1319f5
Merge branch 'testnet3' of https://github.com/AleoHQ/sdk into feat/we…
onetrickwolf Jun 29, 2023
93b8396
setting preinstall back to specific nightly, updating Cargo.lock
onetrickwolf Jun 29, 2023
229ecb4
reverting patch and imported worker format
onetrickwolf Jun 30, 2023
ce571fc
reintroducing webpack
onetrickwolf Jun 30, 2023
fd5f199
reverting lock
onetrickwolf Jun 30, 2023
248766c
reverting lock
onetrickwolf Jun 30, 2023
f37aab0
reverting lock
onetrickwolf Jun 30, 2023
989e739
updating readme to include netlify preview
onetrickwolf Jun 30, 2023
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ storage*/
rust/src/.DS_Store
rust/src/program/.DS_Store


# Local Netlify folder
.netlify
15 changes: 15 additions & 0 deletions website/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': 'warn',
},
}
24 changes: 24 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
75 changes: 18 additions & 57 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,31 @@
# Aleo SDK Website

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
This project was bootstrapped with [Vite](https://vitejs.dev/).

## Available Scripts

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
## Getting Started

### `yarn eject`
### Prerequisites

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
- Follow [SDK Build Guide](https://github.com/AleoHQ/sdk#2-build-guide) to get Rust installed
- Nodejs `18` or `20`. Install through [official website](https://nodejs.org/) or via a node manager like [NVM](https://github.com/creationix/nvm)

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
```bash
rustup component add rust-src --toolchain nightly-2023-05-24-aarch64-apple-darwin
npm install
npm run dev
```

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
Open [http://localhost:5173](http://localhost:5173) to view it in the browser.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration
## Available Scripts

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
In the project directory, you can run:

### Deployment
### `preview:netlify`

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
Locally preview production build.

### `yarn build` fails to minify
### `npm run build`

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
Builds the app for production to the `dist` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
21 changes: 21 additions & 0 deletions website/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="public/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="A Software Development Kit (SDK) for Zero-Knowledge Transactions"
/>
<link rel="apple-touch-icon" href="public/logo129.png" />
<link rel="manifest" href="public/manifest.json" />
<title>Aleo SDK</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
</body>
</html>
52 changes: 22 additions & 30 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
"name": "aleo-website",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"preinstall": "cd ../wasm && export RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--max-memory=4294967296' && rustup run nightly-2023-05-24 wasm-pack build --release --target web --out-dir pkg-parallel -- --features \"parallel, browser\" --no-default-features -Z build-std=panic_abort,std",
"dev": "vite",
"build": "webpack --config webpack.config.js",
"build:vite": "vite build",
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"preview:netlify": "npm run build && netlify dev --dir=dist"
},
"dependencies": {
"@aleohq/ui": "^0.0.9",
"@aleohq/wasm": "file:../wasm/pkg-parallel",
Expand All @@ -11,48 +21,30 @@
"babel-loader": "^8.2.3",
"copy-to-clipboard": "^3.3.1",
"gh-pages": "^3.1.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"web-vitals": "^0.2.4"
},
"devDependencies": {
"@babel/core": "^7.17.2",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@wasm-tool/wasm-pack-plugin": "^1.3.1",
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react-swc": "^3.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.6.0",
"eslint": "^8.38.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.5.3",
"netlify-cli": "^15.7.0",
"style-loader": "^3.3.1",
"vite": "^4.3.9",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.7.4"
},
"scripts": {
"preinstall": "cd ../wasm && export RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--max-memory=4294967296' && rustup run nightly-2023-05-24 wasm-pack build --release --target web --out-dir pkg-parallel -- --features \"parallel, browser\" --no-default-features -Z build-std=panic_abort,std",
"start": "webpack-dev-server",
"build": "webpack --config webpack.config.js",
"predeploy": "yarn build",
"deploy": "gh-pages -d build",
"clean": "rm -rf nodeg_modules"
},
"eslintConfig": {
"extends": [
"react-app"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"webpack-cli": "^5.1.4"
},
"homepage": "https://aleo.tools"
}
43 changes: 0 additions & 43 deletions website/public/index.html

This file was deleted.

File renamed without changes.
File renamed without changes.
13 changes: 7 additions & 6 deletions website/src/index.js → website/src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { createRoot } from 'react-dom/client';

import '@aleohq/ui/dist/bundle.css';

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
const container = document.getElementById('root');
const root = createRoot(container);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

const reportWebVitals = onPerfEntry => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ export const VerifyMessage = () => {
const layout = {labelCol: {span: 3}, wrapperCol: {span: 21}};
useEffect(() => {
if ( !didMount.current ) {
return didMount.current = true;
didMount.current = true;
} else {
attemptVerify()
}
attemptVerify()
}, [messageInput, signatureInput, inputAddress, verified]);
if (aleo !== null) {
const messageString = () => messageInput !== null ? messageInput.toString() : "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export const Deploy = () => {
const [transactionID, setTransactionID] = useState(null);
const [worker, setWorker] = useState(null);
function spawnWorker() {
let worker = new Worker("./worker.js");
let worker = new Worker(
new URL('../../workers/worker.js', import.meta.url),
{type: 'module'}
);
worker.addEventListener("message", ev => {
if (ev.data.type == 'DEPLOY_TRANSACTION_COMPLETED') {
let [deployTransaction, url] = ev.data.deployTransaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export const Execute = () => {
}

function spawnWorker() {
let worker = new Worker("./worker.js");
let worker = new Worker(
new URL('../../workers/worker.js', import.meta.url),
{type: 'module'}
);
worker.addEventListener("message", ev => {
if (ev.data.type == 'OFFLINE_EXECUTION_COMPLETED') {
setLoading(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export const Join = () => {
const [worker, setWorker] = useState(null);

function spawnWorker() {
let worker = new Worker("./worker.js");
let worker = new Worker(
new URL('../../workers/worker.js', import.meta.url),
{type: 'module'}
);
worker.addEventListener("message", ev => {
if (ev.data.type == 'JOIN_TRANSACTION_COMPLETED') {
let [transaction, url] = ev.data.joinTransaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export const Split = () => {
const [worker, setWorker] = useState(null);

function spawnWorker() {
let worker = new Worker("./worker.js");
let worker = new Worker(
new URL('../../workers/worker.js', import.meta.url),
{type: 'module'}
);
worker.addEventListener("message", ev => {
if (ev.data.type == 'SPLIT_TRANSACTION_COMPLETED') {
let [transaction, url] = ev.data.splitTransaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export const Transfer = () => {
const [provingKey, setProvingKey] = useState(null);

function spawnWorker() {
let worker = new Worker("./worker.js");
let worker = new Worker(
new URL('../../workers/worker.js', import.meta.url),
{type: 'module'}
);
worker.addEventListener("message", ev => {
if (ev.data.type == 'TRANSFER_TRANSACTION_COMPLETED') {
let [transaction, url] = ev.data.transferTransaction
Expand Down
2 changes: 1 addition & 1 deletion website/src/workers/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import init, * as aleo from '@aleohq/wasm';
import { FEE_PROVER_URL, FEE_VERIFIER_URL, JOIN_PROVER_URL, JOIN_VERIFIER_URL, SPLIT_PROVER_URL, SPLIT_VERIFIER_URL,
TRANSFER_PRIVATE_PROVER_URL, TRANSFER_PRIVATE_VERIFIER_URL, TRANSFER_PRIVATE_TO_PUBLIC_PROVER_URL,
TRANSFER_PRIVATE_TO_PUBLIC_VERIFIER_URL, TRANSFER_PUBLIC_PROVER_URL, TRANSFER_PUBLIC_VERIFIER_URL,
TRANSFER_PUBLIC_TO_PRIVATE_PROVER_URL, TRANSFER_PUBLIC_TO_PRIVATE_VERIFIER_URL} from './keys';
TRANSFER_PUBLIC_TO_PRIVATE_PROVER_URL, TRANSFER_PUBLIC_TO_PRIVATE_VERIFIER_URL} from './keys.js';

let feeProvingKey = null;
let feeVerifyingKey = null;
Expand Down
Loading