Skip to content

Commit

Permalink
[FE] Use path aliases for app dependencies (MystenLabs#4340)
Browse files Browse the repository at this point in the history
* Use path aliases for app dependencies

* Fix all builds

* Keep package overrides

* Revert overrides change

* Use path alias for bcs in tests

* Remove jest and fix wallet tests

* Run install

* Debug wallet

* Move to shared runners
  • Loading branch information
Jordan-Mysten authored Aug 31, 2022
1 parent 32adf05 commit 81b8dd3
Show file tree
Hide file tree
Showing 23 changed files with 142 additions and 1,509 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ sui_core/tests/staged/sui.yaml text eol=lf

# These files is auto generated
sdk/typescript/src/index.guard.ts linguist-generated=true
sdk/typescript/src/rpc/client.guard.ts linguist-generated=true
4 changes: 0 additions & 4 deletions .github/workflows/explorer-client-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build SDK
run: pnpm --filter @mysten/sui.js build
- name: Lint
run: pnpm --filter sui-explorer lint
- name: Unit Tests
Expand All @@ -54,8 +52,6 @@ jobs:
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build TS sdk
run: pnpm --filter @mysten/sui.js build
- name: Install Cypress
run: pnpm --filter sui-explorer exec cypress install
- name: Run e2e tests
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/wallet-ext-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Wallet Extension PR checks
on: pull_request
jobs:
diff:
runs-on: [ubuntu-ghcloud]
runs-on: [ubuntu-latest]
outputs:
isWalletExt: ${{ steps.diff.outputs.isWalletExt }}
steps:
Expand All @@ -14,7 +14,7 @@ jobs:
name: Lint, Test & Build
needs: diff
if: needs.diff.outputs.isWalletExt == 'true'
runs-on: [ubuntu-ghcloud]
runs-on: [ubuntu-latest]
env:
working-directory: ./wallet
steps:
Expand All @@ -30,8 +30,6 @@ jobs:
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build SDK
run: pnpm --filter @mysten/sui.js build
- name: Lint
working-directory: ${{env.working-directory}}
run: pnpm lint
Expand Down
2 changes: 1 addition & 1 deletion explorer/client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module.exports = {
plugins: ['header'],
extends: ['react-app', 'react-app/jest', 'prettier'],
extends: ['react-app', 'prettier'],
rules: {
'react/jsx-no-bind': ['error'],
'import/order': [
Expand Down
11 changes: 0 additions & 11 deletions explorer/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ Dependencies are managed using [`pnpm`](https://pnpm.io/). You can start by inst
$ pnpm install
```

Currently the Explorer depends on an unreleased version of `sui.js`, the TypeScript SDK for Sui. Therefore, you need to build the SDK first:

```bash
$ pnpm --filter @mysten/sui.js... build
```

> **Note:** If you are updating the SDK and Explorer at the same time, you need to re-build the SDK whenever you makes changes for it to be reflected in the Explorer.
# How to Switch Environment

## Connecting to the DevNet Remote Gateway Server
Expand All @@ -28,7 +20,6 @@ The Sui Explorer frontend will use the DevNet Gateway server by default: https:/

```bash
pnpm dev

```

## Connecting to a Local RPC Server
Expand All @@ -37,7 +28,6 @@ Refer to [Local RPC Server & JSON-RPC API Quick Start](../../doc/src/build/json-

```bash
pnpm dev:local

```

Alternatively, having run `pnpm dev`, click the green button at the top of the page and select the option 'Local'.
Expand All @@ -48,7 +38,6 @@ First run the following:

```bash
pnpm dev

```

Then, click the green button at the top and select the option 'Custom RPC URL'. Type the Custom RPC URL into the input box that emerges.
Expand Down
7 changes: 6 additions & 1 deletion explorer/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@mysten/sui.js": ["../../sdk/typescript/src/"],
"@mysten/bcs": ["../../sdk/typescript/bcs/src/"]
}
},
"include": ["src"]
}
13 changes: 13 additions & 0 deletions explorer/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import react from '@vitejs/plugin-react';
import path from 'path';
import { defineConfig } from 'vite';
import svgr from 'vite-plugin-svgr';

Expand All @@ -12,4 +13,16 @@ export default defineConfig({
// Set the output directory to match what CRA uses:
outDir: 'build',
},
resolve: {
alias: {
'@mysten/sui.js': path.resolve(
__dirname,
'../../sdk/typescript/src/'
),
'@mysten/bcs': path.resolve(
__dirname,
'../../sdk/typescript/bcs/src/'
),
},
},
});
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"pnpm": {
"overrides": {
"node-notifier": "10.0.0",
"jest": "27",
"ts-jest": "27",
"async": "3.2.2",
"nth-check": "2.0.1"
}
Expand Down
Loading

0 comments on commit 81b8dd3

Please sign in to comment.