Skip to content

Commit

Permalink
feat: migrate from parcel to vite
Browse files Browse the repository at this point in the history
  • Loading branch information
nikaaru committed Jul 9, 2024
1 parent 9dea888 commit 8f1e5fa
Show file tree
Hide file tree
Showing 9 changed files with 595 additions and 48 deletions.
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"node": ">=20",
"npm": "please-use-yarn"
},
"workspaces": [
"workspaces": {"packages": [
"examples/*",
"widget/*",
"queue-manager/*",
"wallets/*",
"signers/*",
"logging/*"
],
"nohoist": ["**/ethers"]
},
"scripts": {
"clean-root": "rimraf .parcel-cache && nx clear-cache",
"clean": "yarn clean-root && nx run-many --target=clean",
Expand Down Expand Up @@ -53,8 +55,10 @@
},
"dependencies": {
"husky": "^8.0.3",
"node-stdlib-browser": "^1.2.0",
"tslib": "^2.4.1",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vite-plugin-node-stdlib-browser": "^0.2.1"
},
"devDependencies": {
"@actions/core": "^1.10.1",
Expand All @@ -69,6 +73,7 @@
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"@vercel/routing-utils": "^3.1.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-v8": "^0.33.0",
"buffer": "^5.5.0",
"chalk": "^5.2.0",
Expand Down Expand Up @@ -105,12 +110,10 @@
"stream-browserify": "^3.0.0",
"tty-browserify": "^0.0.1",
"util": "^0.12.3",
"vite": "^5.3.3",
"vitest": "^0.33.0",
"vm-browserify": "^1.1.2"
},
"resolutions": {
"react-refresh": "0.9.0"
},
"@parcel/resolver-default": {
"packageExports": true
}
Expand Down
6 changes: 5 additions & 1 deletion wallets/shared/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import type { EvmBlockchainMeta } from 'rango-types';

import { Networks } from './rango';

export { isAddress as isEvmAddress } from 'ethers/lib/utils.js';
// export { isAddress as isEvmAddress } from 'ethers/lib/utils.js';

export function isEvmAddress(ss: string) {
return ss === undefined;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function deepCopy(obj: any): any {
Expand Down
4 changes: 2 additions & 2 deletions widget/app/public/index.html → widget/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
content="width=device-width, initial-scale=1, maximum-scale=1"
/>
<title>Rango Widget</title>
<link rel="stylesheet" href="index.css" />
<link rel="stylesheet" href="/index.css" />
</head>
<body>
<div id="app"></div>
<script type="module" src="../src/index.tsx"></script>
<script type="module" src="./src/index.tsx"></script>
</body>
</html>
9 changes: 5 additions & 4 deletions widget/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
"version": "0.16.0",
"license": "MIT",
"private": true,
"source": "public/index.html",
"source": "index.html",
"main": "dist/index.html",
"type": "module",
"targets": {
"main": false
},
"browserslist": "> 0.5%, last 2 versions, not dead",
"scripts": {
"dev": "parcel -p 3002 --cache-dir=.parcel-cache --no-cache",
"build": "parcel build --cache-dir=.parcel-cache",
"dev": "vite --port 3002 --force",
"build": "vite build",
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
"clean": "rimraf .parcel-cache && rimraf dist",
"clean": "rimraf dist",
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
},
Expand Down
35 changes: 24 additions & 11 deletions widget/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"module": "esnext",
"outDir": "dist",
"lib": ["dom", "esnext"],
// match output dir to input dir. e.g. dist/index instead of dist/src/index
"rootDir": "./src",
// transpile JSX to React.createElement
"jsx": "react"
}
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
30 changes: 30 additions & 0 deletions widget/app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import ViteNodePolyfills from 'vite-plugin-node-stdlib-browser';

export default defineConfig({
build: {
outDir: './dist', // Output directory for the build (relative to the root)
},
plugins: [react(), ViteNodePolyfills()],
optimizeDeps: {
disabled: true,
/*
* exclude: [
* 'ethers',
* '@rango-dev/provider-ledger > ethers',
* '@rango-dev/provider-trezor > ethers',
* ],
*/

/*
* include: [
* '@rango-dev/provider-ledger>@ledgerhq/errors',
* '@rango-dev/provider-ledger>@ledgerhq/hw-app-eth',
* '@rango-dev/provider-ledger>@ledgerhq/hw-app-solana',
* '@rango-dev/provider-ledger>@ledgerhq/hw-transport-webhid',
* '@rango-dev/provider-trezor>@trezor/connect-web',
* ],
*/
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="./favicon.png" />
<link rel="icon" href="/favicon.png" />
<title>Rango Widget Playground</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="../src/styles.css" />
<link rel="stylesheet" href="./src/styles.css" />
</head>
<body>
<div id="app"></div>
<script type="module" src="../src/index.tsx"></script>
<script type="module" src="./src/index.tsx"></script>
</body>
</html>
8 changes: 4 additions & 4 deletions widget/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"version": "0.16.0",
"license": "MIT",
"private": true,
"source": "public/index.html",
"source": "index.html",
"main": "dist/index.html",
"targets": {
"main": false
},
"browserslist": "> 0.5%, last 2 versions, not dead",
"scripts": {
"dev": "parcel -p 3005 --cache-dir=.parcel-cache --no-cache",
"build": "parcel build --cache-dir=.parcel-cache",
"dev": "vite --port 3005",
"build": "vite build",
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
"clean": "rimraf .parcel-cache && rimraf dist",
"clean": "rimraf dist",
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
},
Expand Down
Loading

0 comments on commit 8f1e5fa

Please sign in to comment.