From ee963717c3d08d305caf9a9fd86fc3370f11c309 Mon Sep 17 00:00:00 2001 From: Andreas Philippi Date: Tue, 20 Aug 2024 12:36:48 +0200 Subject: [PATCH] chore: bundle library, emit type declarations --- .storybook/preview.ts | 4 ++-- package.json | 24 ++++++++++++++++++++++-- src/primevue/index.ts | 2 +- tsconfig.json | 2 +- tsconfig.lib.json | 17 +++++++++++++++++ vite.config.ts | 6 ++++-- 6 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 tsconfig.lib.json diff --git a/.storybook/preview.ts b/.storybook/preview.ts index f9036f0..5f0868e 100644 --- a/.storybook/preview.ts +++ b/.storybook/preview.ts @@ -1,10 +1,10 @@ import { setup } from "@storybook/vue3"; import PrimeVue from "primevue/config"; -import preset from "../src/primevue"; +import { RisUi } from "../src/primevue"; setup((app) => { app.use(PrimeVue, { - pt: preset, + pt: RisUi, unstyled: true, }); }); diff --git a/package.json b/package.json index 95d8484..491bf09 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,31 @@ { "name": "ris-ui", - "private": true, "version": "0.0.0", + "private": false, + "description": "Component library for NeuRIS", + "author": "TBD.", + "license": "GPL-3.0-only", "type": "module", + "repository": "https://github.com/digitalservicebund/ris-ui", + "files": [ + "dist" + ], + "exports": { + ".": { + "import": "./dist/primevue.js", + "types": "./dist/primevue/index.d.ts" + }, + "./style.css": { + "import": "./dist/style.css" + }, + "./tailwind": { + "import": "./dist/tailwind.js", + "types": "./dist/tailwind/index.d.ts" + } + }, "scripts": { "storybook": "storybook dev -p 6006", - "build": "vue-tsc -b && vite build", + "build": "vite build; vue-tsc -p tsconfig.lib.json", "build:storybook": "storybook build", "prettier:check": "prettier --check .", "prettier:fix": "prettier --write --ignore-unknown ." diff --git a/src/primevue/index.ts b/src/primevue/index.ts index 97b691d..e0fd858 100644 --- a/src/primevue/index.ts +++ b/src/primevue/index.ts @@ -6,7 +6,7 @@ import inputGroupAddon from "./inputGroup/inputGroupAddon"; import inputText from "./inputText/inputText"; import password from "./password/password"; -export default { +export const RisUi = { button, inputText, inputGroup, diff --git a/tsconfig.json b/tsconfig.json index 21c1542..7f81a26 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "module": "ESNext", "skipLibCheck": true, "target": "ES2020", - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo", "useDefineForClassFields": true, /* Bundler mode */ diff --git a/tsconfig.lib.json b/tsconfig.lib.json new file mode 100644 index 0000000..8be4f4e --- /dev/null +++ b/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.lib.tsbuildinfo", + + /* Build output */ + "declaration": true, + "emitDeclarationOnly": true, + "noEmit": false, + "outDir": "dist", + "rootDir": "./src" + }, + + "include": ["src/**/*.ts"], + "exclude": ["src/**/*.stories.ts"] +} diff --git a/vite.config.ts b/vite.config.ts index 3e86a3f..459ba37 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -22,8 +22,10 @@ export default defineConfig({ build: { lib: { - entry: "src/primevue/index.ts", - name: "ris-ui", + entry: { + primevue: "src/primevue/index.ts", + tailwind: "src/tailwind/index.ts", + }, formats: ["es"], }, rollupOptions: {