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

Migrate to Vite #352

Merged
merged 16 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 8 additions & 8 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node from .nvmrc
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Build the extension
run: yarn build
- name: Cache build artifacts
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: packages/extension/build
key: ${{ runner.os }}-build-${{ github.sha }}
Expand All @@ -38,9 +38,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node from .nvmrc
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -53,9 +53,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node from .nvmrc
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
Expand All @@ -64,7 +64,7 @@ jobs:
- name: Cypress run
uses: cypress-io/github-action@v5
with:
start: yarn start
start: yarn dev
wait-on: 'http://localhost:3000'
wait-on-timeout: 120
browser: chrome
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.19.0
20.11.1
26 changes: 8 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
"version": "1.0.0",
"description": "Monorepo related to the GemWallet extension",
"private": true,
"repository": "https://github.com/GemWallet/poc-vitejs.git",
"scripts": {
"build": "NODE_OPTIONS=--openssl-legacy-provider yarn workspace @gemwallet/extension build",
"prepare": "husky install",
"build": "yarn workspace @gemwallet/extension build",
"build:api:cdn": "yarn workspace @gemwallet/api build:cdn",
"build:api:npm": "yarn workspace @gemwallet/api build:npm",
"cypress": "yarn workspace @gemwallet/extension cypress:e2e",
"lint": "eslint --cache --quiet --fix",
"prepare": "husky install",
"prettier": "prettier --write **/*.{js,ts,tsx}",
"release:api:npm": "cd packages/api/dist && npm publish --access=public",
"start": "NODE_OPTIONS=--openssl-legacy-provider yarn workspace @gemwallet/extension start",
"start": "yarn workspace @gemwallet/extension dev",
"start:api": "yarn workspace @gemwallet/api start",
"test": "TZ=UTC yarn workspaces run test --runInBand"
},
"repository": {
"type": "git",
"url": "git+https://github.com/GemWallet/gemwallet-extension.git"
"test": "TZ=UTC yarn workspaces run test",
"cypress": "yarn workspace @gemwallet/extension cypress:e2e",
"prettier": "prettier --write **/*.{js,ts,tsx}"
},
"author": "GemWallet",
"bugs": {
Expand All @@ -33,7 +28,7 @@
"dependencies": {
"husky": "^7.0.4",
"lint-staged": "^12.0.2",
"prettier": "^2.4.1"
"prettier": "^3.2.4"
},
"lint-staged": {
"**/*.{js,ts,tsx}": [
Expand All @@ -43,10 +38,5 @@
"**/*.{json,md,html}": [
"prettier --write"
]
},
"engines": {
"node": ">=18.19.0",
"npm": ">=10.2.3",
"yarn": "^1.22.5"
}
}
17 changes: 9 additions & 8 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
"homepage": "https://github.com/GemWallet/gemwallet-extension#readme",
"devDependencies": {
"@gemwallet/constants": "*",
"@types/jest": "^26.0.15",
"@types/jest": "^29.5.12",
"clean-webpack-plugin": "^4.0.0",
"html-webpack-plugin": "^5.5.0",
"jest": "^26.6.0",
"prettier": "^2.7.1",
"ts-jest": "^26.5.6",
"html-webpack-plugin": "^5.6.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "^3.2.5",
"ts-jest": "^29.1.2",
"ts-loader": "^9.2.6",
"typescript": "^4.5.4",
"webpack": "^5.87.0",
"typescript": "^5.3.3",
"webpack": "^5.90.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.7.3"
"webpack-dev-server": "^4.15.1"
}
}
Empty file modified packages/api/src/index.ts
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion packages/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
},
"homepage": "https://github.com/GemWallet/gemwallet-extension#readme",
"peerDependencies": {
"xrpl": "^2.11.0"
"xrpl": "^3.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/constants/src/event/event.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export type EventListener =
| SubmitBulkTransactionsEventListener;

// Events
interface EventEventData {
export interface EventEventData {
app: typeof GEM_WALLET;
type: EventMessage;
source: 'GEM_WALLET_MSG_REQUEST';
Expand Down
8 changes: 4 additions & 4 deletions packages/constants/src/payload/payload.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccountSetAsfFlags, Path, Transaction } from 'xrpl';
import { AccountSetAsfFlags, Path, SubmittableTransaction } from 'xrpl';
import { Amount, IssuedCurrencyAmount } from 'xrpl/dist/npm/models/common';

import { Network } from '../network/network.constant';
Expand Down Expand Up @@ -265,14 +265,14 @@ export interface CancelOfferRequest extends BaseTransactionRequest {
}

export interface SubmitTransactionRequest {
transaction: Transaction;
transaction: SubmittableTransaction;
}

export interface SignTransactionRequest {
transaction: Transaction;
transaction: SubmittableTransaction;
}

export type TransactionWithID = Transaction & {
export type TransactionWithID = SubmittableTransaction & {
// Optional ID to identify the transaction in the response, after it has been submitted.
// This id is only used as an indicator in the response, and is not used to order transactions.
ID?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/constants/src/xrpl/basic.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
OfferCreateFlagsInterface,
AMMDepositFlagsInterface,
AMMWithdrawFlagsInterface,
Transaction as XRPLTx
SubmittableTransaction as XRPLTx
} from 'xrpl';

import { SetHook } from './hooks.types';
Expand Down
18 changes: 18 additions & 0 deletions packages/extension/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
42 changes: 20 additions & 22 deletions packages/extension/.gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# eslint
.eslintcache
node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
70 changes: 21 additions & 49 deletions packages/extension/README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,30 @@
# GemWallet Extension
# React + TypeScript + Vite

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

## Getting Started
Currently, two official plugins are available:

Run the development server:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

```bash
npm run 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.
## Expanding the ESLint configuration

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

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

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

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.

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.

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/).
- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname
}
};
```

```
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
50 changes: 0 additions & 50 deletions packages/extension/craco.config.js

This file was deleted.

17 changes: 17 additions & 0 deletions packages/extension/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./fonts/roboto.css" />
<link rel="apple-touch-icon" href="logo192.png" />
<link rel="manifest" href="manifest.json" />
<title>GemWallet</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
Loading
Loading