Skip to content

Commit

Permalink
feat: wasm analyzer implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxilly committed May 26, 2024
1 parent 9146848 commit 18db147
Show file tree
Hide file tree
Showing 16 changed files with 2,829 additions and 974 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
artifactErrorsFailBuild: true
allowUpdates: true
artifactContentType: 'text/html'
artifacts: 'ui/dist/index.html'
artifacts: 'ui/dist/webui/index.html'
tag: ui-v1
commit: master
prerelease: true
Expand All @@ -74,7 +74,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ui
path: ui/dist/index.html
path: 'ui/dist/webui/index.html'



3 changes: 1 addition & 2 deletions cmd/wasm/main_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func analyze(_ js.Value, args []js.Value) any {
}

func main() {
wait := make(chan struct{})
js.Global().Set("gsa_analyze", js.FuncOf(analyze))
<-wait
select {}
}
26 changes: 10 additions & 16 deletions ui/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import react from "@vitejs/plugin-react";
import {BuildOptions, PluginOption} from "vite";
import {codecovVitePlugin} from "@codecov/vite-plugin";
import * as path from "node:path";


export function getSha(): string | undefined {
Expand All @@ -20,8 +21,13 @@ export function getSha(): string | undefined {
}

export function codecov(name: string): PluginOption {
if (process.env.CODECOV_TOKEN === undefined) {
console.warn("CODECOV_TOKEN is not set, codecov plugin will be disabled");
return undefined;
}

return codecovVitePlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
enableBundleAnalysis: true,
bundleName: name,
uploadToken: process.env.CODECOV_TOKEN,
uploadOverrides: {
Expand All @@ -33,24 +39,12 @@ export function codecov(name: string): PluginOption {

export function commonPlugin(): PluginOption[][] {
return [
react({
babel: {
plugins: ["babel-plugin-react-compiler"]
}
}),
react(),
]
}

export function build(): BuildOptions {
export function build(dir: string): BuildOptions {
return {
cssMinify: "lightningcss",
minify: "terser",
terserOptions: {
compress: {
passes: 2,
ecma: 2020,
dead_code: true,
}
}
outDir: path.join("dist", dir),
}
}
5 changes: 3 additions & 2 deletions ui/index-explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>GSA TreeMap</title>
<script src="./src/tool/wasm_exec.js"></script>
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/main.tsx"></script>
<div id="root"></div>
<script type="module" src="./src/explorer_main.tsx"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script type="application/json" id="data">"GSA_PACKAGE_DATA"</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/main.tsx"></script>
<div id="root"></div>
<script type="module" src="./src/main.tsx"></script>
</body>
</html>
33 changes: 15 additions & 18 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,39 @@
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
},
"dependencies": {
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"d3-array": "^3.2.4",
"d3-color": "^3.1.0",
"d3-hierarchy": "^3.1.2",
"d3-scale": "^4.0.2",
"react": "19.0.0-beta-26f2496093-20240514",
"react-dom": "19.0.0-beta-26f2496093-20240514",
"usehooks-ts": "^3.1.0"
"framer-motion": "^11.2.6",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-use": "^17.5.0"
},
"devDependencies": {
"@codecov/vite-plugin": "0.0.1-beta.6",
"@codecov/vite-plugin": "0.0.1-beta.8",
"@types/d3-array": "^3.2.1",
"@types/d3-color": "^3.1.3",
"@types/d3-hierarchy": "^3.1.7",
"@types/d3-scale": "^4.0.8",
"@types/golang-wasm-exec": "^1.15.2",
"@types/node": "^20.12.12",
"@types/react": "npm:types-react@beta",
"@types/react-dom": "npm:types-react-dom@beta",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"@vitejs/plugin-react": "^4.2.1",
"babel-plugin-react-compiler": "0.0.0-experimental-592953e-20240517",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"@vitejs/plugin-react": "^4.3.0",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-compiler": "0.0.0-experimental-c8b3f72-20240517",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"lightningcss": "^1.25.0",
"sass": "^1.77.2",
"terser": "^5.31.0",
"typescript": "^5.4.5",
"typia": "^6.0.3",
"typia": "^6.0.4",
"vite": "^5.2.11",
"vite-plugin-singlefile": "^2.0.1"
},
"overrides": {
"@types/react": "npm:types-react@beta",
"@types/react-dom": "npm:types-react-dom@beta"
}
}
Loading

0 comments on commit 18db147

Please sign in to comment.