Skip to content

Commit

Permalink
perf(dashboard): optimise unnecessary dependencies (#24)
Browse files Browse the repository at this point in the history
* chore(core): upgrade deps

* perf(dashboard): remove tiny invariant dep

* perf(dashboard): remove unused css

* perf: use postcss-lightningcss

* temp

* fix: apply missing styles

* chore: cleanup unused deps
  • Loading branch information
ayuhito authored Jun 13, 2024
1 parent 5842e53 commit e770505
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 27 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions core/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/marcboeker/go-duckdb v1.7.0
github.com/medama-io/go-timezone-country v0.0.0-20240125021558-8a6127efd8f7
github.com/medama-io/go-useragent v0.0.0-20231118151641-642da8a8a685
github.com/ncruces/go-sqlite3 v0.16.1
github.com/ncruces/go-sqlite3 v0.16.2
github.com/ogen-go/ogen v1.2.1
github.com/rs/cors v1.11.0
github.com/rs/zerolog v1.33.0
Expand All @@ -33,7 +33,7 @@ require (
github.com/gofrs/uuid/v5 v5.2.0 // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -43,7 +43,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/tetratelabs/wazero v1.7.2 // indirect
github.com/tetratelabs/wazero v1.7.3 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions core/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand All @@ -62,8 +62,8 @@ github.com/medama-io/go-useragent v0.0.0-20231118151641-642da8a8a685 h1:x9wlwJuE
github.com/medama-io/go-useragent v0.0.0-20231118151641-642da8a8a685/go.mod h1:H9GYWth4IN8vAFZh5LeARza7VwM4jK9uk7Tb9huVzLw=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/ncruces/go-sqlite3 v0.16.1 h1:1wHv7s8y+fWK44UIliotJ42ZV41A5T0sjIAqGmnMrkc=
github.com/ncruces/go-sqlite3 v0.16.1/go.mod h1:feFXbBcbLtxNk6XWG1ROt8MS9+E45yCW3G8o4ixIqZ8=
github.com/ncruces/go-sqlite3 v0.16.2 h1:HesVRr0BC6QSGSEQfEXOntFWS9wd4Z8ms4nJzfUv4Rg=
github.com/ncruces/go-sqlite3 v0.16.2/go.mod h1:wkUIvOrAjFQnefVlivJfcowKUcfMHs4mvLfhVanzHHI=
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
github.com/ogen-go/ogen v1.2.1 h1:C5A0lvUMu2wl+eWIxnpXMWnuOJ26a2FyzR1CIC2qG0M=
Expand All @@ -85,8 +85,8 @@ github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc=
github.com/tetratelabs/wazero v1.7.2/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y=
github.com/tetratelabs/wazero v1.7.3 h1:PBH5KVahrt3S2AHgEjKu4u+LlDbbk+nsGE3KLucy6Rw=
github.com/tetratelabs/wazero v1.7.3/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
Expand Down
37 changes: 34 additions & 3 deletions dashboard/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
import '@mantine/core/styles.layer.css';
import 'mantine-datatable/styles.layer.css';
import '@fontsource-variable/inter/wght.css';
// Comman
import '@mantine/core/styles/global.css';
import '@mantine/core/styles/ScrollArea.css';
import '@mantine/core/styles/UnstyledButton.css';
import '@mantine/core/styles/VisuallyHidden.css';
import '@mantine/core/styles/Paper.css';
import '@mantine/core/styles/Popover.css';
import '@mantine/core/styles/Group.css';
import '@mantine/core/styles/Input.css';
import '@mantine/core/styles/Flex.css';
import '@mantine/core/styles/InlineInput.css';
// Layout
import '@mantine/core/styles/SimpleGrid.css';
import '@mantine/core/styles/Container.css';
import '@mantine/core/styles/Stack.css';
// Buttons
import '@mantine/core/styles/ActionIcon.css';
import '@mantine/core/styles/Button.css';
import '@mantine/core/styles/CloseButton.css';
// Inputs
import '@mantine/core/styles/Checkbox.css';
import '@mantine/core/styles/Combobox.css';
import '@mantine/core/styles/PasswordInput.css';
// Navigation
import '@mantine/core/styles/Burger.css';
import '@mantine/core/styles/NavLink.css';
import '@mantine/core/styles/Tabs.css';
// Feedback
import '@mantine/core/styles/Skeleton.css';
// Misc
import '@mantine/core/styles/Text.css';
import '@mantine/core/styles/Anchor.css';
import '@mantine/core/styles/Title.css';
import '@/styles/global.css';
import 'mantine-datatable/styles.css';

import { enableReactUse } from '@legendapp/state/config/enableReactUse';
import { ColorSchemeScript, MantineProvider } from '@mantine/core';
import {
json,
type ClientLoaderFunctionArgs,
isRouteErrorResponse,
Links,
Meta,
Expand Down
8 changes: 3 additions & 5 deletions dashboard/app/routes/$hostname.$query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {

import { StatsTable } from '@/components/stats/StatsTable';
import { type DatasetItem, fetchStats, isDatasetItem } from '@/utils/stats';
import invariant from 'tiny-invariant';

export const meta: MetaFunction = () => {
return [{ title: 'Dashboard | Medama' }];
Expand All @@ -19,10 +18,9 @@ export const clientLoader = async ({
params,
}: ClientLoaderFunctionArgs) => {
const query = params.query as DatasetItem;
invariant(
!query || (isDatasetItem(query) && params.query !== 'summary'),
'Invalid dataset item',
);
if (!query || (isDatasetItem(query) && params.query !== 'summary')) {
throw new Error('Invalid dataset item');
}

const stats = await fetchStats(request, params, {
dataset: [query],
Expand Down
3 changes: 1 addition & 2 deletions dashboard/app/routes/$hostname.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Outlet,
useLoaderData,
} from '@remix-run/react';
import invariant from 'tiny-invariant';

import { StackedBarChart } from '@/components/stats/Chart';
import { Filters } from '@/components/stats/Filter';
Expand All @@ -31,7 +30,7 @@ export const clientLoader = async ({

export default function Index() {
const { summary } = useLoaderData<typeof clientLoader>();
invariant(summary, 'Summary data is required');
if (!summary) throw new Error('Summary data is required');

return (
<>
Expand Down
12 changes: 5 additions & 7 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"dependencies": {
"@fontsource-variable/inter": "^5.0.18",
"@legendapp/state": "^2.1.14",
"@mantine/core": "^7.10.1",
"@mantine/hooks": "^7.10.1",
"@mantine/core": "^7.10.2",
"@mantine/hooks": "^7.10.2",
"@remix-run/react": "^2.9.2",
"@remix-run/serve": "^2.9.2",
"clsx": "^2.1.1",
Expand All @@ -25,21 +25,19 @@
"mantine-datatable": "^7.10.1",
"react": "18.3.0-canary-8039e6d0b-20231026",
"react-dom": "18.3.0-canary-8039e6d0b-20231026",
"recharts": "^2.12.7",
"tiny-invariant": "^1.3.3"
"recharts": "^2.12.7"
},
"devDependencies": {
"@remix-run/dev": "^2.9.2",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"autoprefixer": "^10.4.19",
"openapi-typescript": "^6.7.6",
"postcss": "^8.4.38",
"postcss-lightningcss": "^1.0.0",
"postcss-preset-mantine": "^1.15.0",
"postcss-simple-vars": "^7.0.1",
"typescript": "^5.4.5",
"vite": "^5.2.13",
"vite": "^5.3.0",
"vite-tsconfig-paths": "^4.3.2"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export default {
'mantine-breakpoint-xl': '88em',
},
},
autoprefixer: {},
'postcss-lightningcss': {}
},
};

0 comments on commit e770505

Please sign in to comment.