From c505374ce9e9df98bf4fbdf307766a222a5afd6e Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 23 Jul 2025 12:57:09 -0600 Subject: [PATCH] vite builder optimization --- packages/ui-components/README.md | 5 ++--- packages/ui-components/package.json | 27 +++++++++++++++++++++------ packages/ui-components/vite.config.ts | 11 +++++++++++ pnpm-lock.yaml | 2 +- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/packages/ui-components/README.md b/packages/ui-components/README.md index 32a2d50bd..2461a69e1 100644 --- a/packages/ui-components/README.md +++ b/packages/ui-components/README.md @@ -13,9 +13,8 @@ This is an internal monorepo package. It's automatically available to other pack Components must be imported from their specific paths for optimal tree-shaking: ```typescript -import { LineChart } from '@buster/ui-components/components/charts'; -import { DataTable } from '@buster/ui-components/components/table'; -``` +import { BusterChart } from '@buster/ui-components/components/charts'; + ``` ### Hooks diff --git a/packages/ui-components/package.json b/packages/ui-components/package.json index f622865e2..499077b7a 100644 --- a/packages/ui-components/package.json +++ b/packages/ui-components/package.json @@ -28,11 +28,31 @@ }, "peerDependencies": { "react": "^18.0.0", - "react-dom": "^18.0.0" + "react-dom": "^18.0.0", + "chart.js": "^4.5.0", + "chartjs-adapter-dayjs-4": "^1.0.4", + "chartjs-plugin-annotation": "^3.1.0", + "chartjs-plugin-datalabels": "^2.2.0", + "chartjs-plugin-deferred": "^2.0.0" }, "peerDependenciesMeta": { "react-dom": { "optional": true + }, + "chart.js": { + "optional": false + }, + "chartjs-adapter-dayjs-4": { + "optional": false + }, + "chartjs-plugin-annotation": { + "optional": false + }, + "chartjs-plugin-datalabels": { + "optional": false + }, + "chartjs-plugin-deferred": { + "optional": false } }, "scripts": { @@ -61,11 +81,6 @@ "@tanstack/react-virtual": "^3.13.12", "@testing-library/react": "^16.3.0", "@vitejs/plugin-react": "^4.7.0", - "chart.js": "4.5.0", - "chartjs-adapter-dayjs-4": "^1.0.4", - "chartjs-plugin-annotation": "^3.1.0", - "chartjs-plugin-datalabels": "^2.2.0", - "chartjs-plugin-deferred": "^2.0.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "dayjs": "^1.11.13", diff --git a/packages/ui-components/vite.config.ts b/packages/ui-components/vite.config.ts index 0bf265d7f..b24d17b20 100644 --- a/packages/ui-components/vite.config.ts +++ b/packages/ui-components/vite.config.ts @@ -69,6 +69,12 @@ export default defineConfig({ 'react', 'react-dom', 'react/jsx-runtime', + // Add Chart.js and its plugins as external dependencies + 'chart.js', + 'chartjs-adapter-dayjs-4', + 'chartjs-plugin-annotation', + 'chartjs-plugin-datalabels', + 'chartjs-plugin-deferred', // Exclude test dependencies /\.test\./, /\.stories\./, @@ -91,6 +97,11 @@ export default defineConfig({ react: 'React', 'react-dom': 'ReactDOM', 'react/jsx-runtime': 'ReactJSXRuntime', + 'chart.js': 'Chart', + 'chartjs-adapter-dayjs-4': 'ChartJSAdapterDayJS4', + 'chartjs-plugin-annotation': 'ChartJSAnnotationPlugin', + 'chartjs-plugin-datalabels': 'ChartDataLabels', + 'chartjs-plugin-deferred': 'ChartDeferred', }, }, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4d4cddc5c..f89f676e9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -998,7 +998,7 @@ importers: specifier: ^4.7.0 version: 4.7.0(vite@7.0.5(@types/node@24.0.10)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0)) chart.js: - specifier: 4.5.0 + specifier: ^4.5.0 version: 4.5.0 chartjs-adapter-dayjs-4: specifier: ^1.0.4