From 3526684536dc6c0ac228b84e3f5ff2a2b4662805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Grangier?= Date: Thu, 11 Jul 2024 17:03:55 +0200 Subject: [PATCH] Added DataTable as lib component --- package.json | 17 ++++++++++++++++- src/components/index.ts | 3 +++ tsconfig.json | 5 +++-- tsconfig.node.json | 2 +- vite.config.ts | 12 ++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 src/components/index.ts diff --git a/package.json b/package.json index 1aa0871..626f97b 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,18 @@ "dev": "vite", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" + "preview": "vite preview", + "prepare": "pnpm run build" + }, + "files": [ + "dist" + ], + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/dataviz.es.js", + "require": "./dist/dataviz.umd.js" + } }, "dependencies": { "@radix-ui/react-collapsible": "^1.0.3", @@ -40,5 +51,9 @@ "tailwindcss": "^3.4.4", "typescript": "^5.2.2", "vite": "^5.2.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" } } diff --git a/src/components/index.ts b/src/components/index.ts new file mode 100644 index 0000000..8833448 --- /dev/null +++ b/src/components/index.ts @@ -0,0 +1,3 @@ +import DataTable from "./organisms/DataTable"; + +export default DataTable; diff --git a/tsconfig.json b/tsconfig.json index 5a30f07..34bd34e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,8 +22,9 @@ "baseUrl": ".", "paths": { "@/*": [ - "./src/*" - ] + "./src/*", + ], + "dataviz": [ "./src/components/index.ts" ] } }, "include": ["src"], diff --git a/tsconfig.node.json b/tsconfig.node.json index 97ede7e..a73f089 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -7,5 +7,5 @@ "allowSyntheticDefaultImports": true, "strict": true }, - "include": ["vite.config.ts"] + "include": ["vite.config.ts", "package.json"] } diff --git a/vite.config.ts b/vite.config.ts index b2cd4e0..15749d8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import path from "path" +import * as packageJson from './package.json' export default defineConfig({ plugins: [react()], @@ -9,4 +10,15 @@ export default defineConfig({ "@": path.resolve(__dirname, "./src"), }, }, + build: { + lib: { + entry: path.resolve('src', 'components/index.ts'), + name: 'dataviz', + formats: ['es', 'umd'], + fileName: (format) => `dataviz.${format}.js`, + }, + rollupOptions: { + external: [...Object.keys(packageJson.peerDependencies)], + }, + }, });