diff --git a/package.json b/package.json index fdd16d0..8707216 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "postcss": "^8.4.35", "prettier": "^3.5.3", "tailwindcss": "^3.4.1", + "tsup": "^8.5.0", "typescript": "^5.8.3", "typescript-eslint": "^8.32.1", "vite": "^5.1.4", diff --git a/packages/ui-kit/README.md b/packages/ui-kit/README.md index 4a4d8d3..8e2b5e1 100644 --- a/packages/ui-kit/README.md +++ b/packages/ui-kit/README.md @@ -80,6 +80,7 @@ This package is optimized for use by AI coding agents. We provide specialized do ### For Human Developers - **[📚 Storybook Documentation](https://ui-kit-storybook-url)** - Interactive component explorer +- **[🎯 Select Component Guide](../../docs/select-component-guide.md)** - Complete guide for using the Select component - **[🎨 Design System](./src/docs/)** - Design tokens, patterns, and guidelines - **[🔧 Development Guide](./docs/development.md)** - Contributing and development setup diff --git a/packages/ui-kit/package.json b/packages/ui-kit/package.json index 720a6ae..df9390a 100644 --- a/packages/ui-kit/package.json +++ b/packages/ui-kit/package.json @@ -3,16 +3,16 @@ "version": "0.2.1", "type": "module", "license": "Apache-2.0", - "main": "./dist/ui-kit.umd.cjs", - "module": "./dist/ui-kit.js", + "main": "./dist/index.cjs", + "module": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/ui-kit.js", - "require": "./dist/ui-kit.umd.cjs" + "import": "./dist/index.js", + "require": "./dist/index.cjs" }, - "./dist/style.css": "./dist/style.css" + "./dist/style.css": "./dist/index.css" }, "files": [ "dist/**" @@ -23,7 +23,7 @@ }, "scripts": { "dev": "vite", - "build": "tsc --declaration --emitDeclarationOnly --outDir dist && vite build", + "build": "tsup", "lint": "eslint .", "preview": "vite preview", "test": "vitest run", @@ -90,14 +90,14 @@ "size-limit": [ { "name": "ES Module Bundle", - "path": "dist/ui-kit.js", - "limit": "500 KB", + "path": "dist/index.js", + "limit": "400 KB", "gzip": true }, { - "name": "UMD Bundle", - "path": "dist/ui-kit.umd.cjs", - "limit": "500 KB", + "name": "CommonJS Bundle", + "path": "dist/index.cjs", + "limit": "950 KB", "gzip": true } ], @@ -151,6 +151,7 @@ "size-limit": "^11.2.0", "storybook": "^8.6.14", "tailwindcss": "^3.4.17", + "tsup": "^8.5.0", "typescript-eslint": "^8.32.1", "vite": "^5.4.19", "vitest": "^1.6.1", diff --git a/packages/ui-kit/tsup.config.ts b/packages/ui-kit/tsup.config.ts new file mode 100644 index 0000000..86ffea4 --- /dev/null +++ b/packages/ui-kit/tsup.config.ts @@ -0,0 +1,34 @@ +import { defineConfig } from "tsup"; + +export default defineConfig({ + entry: ["src/index.ts"], + format: ["cjs", "esm"], + dts: true, + sourcemap: true, + clean: true, + external: ["react", "react-dom"], + noExternal: ["nanoid"], + minify: false, + target: "es2020", + outDir: "dist", + platform: "browser", + esbuildOptions: (options) => { + options.jsx = "automatic"; + options.jsxImportSource = "react"; + // Define globals for browser compatibility + options.define = { + global: "globalThis", + "process.env.NODE_ENV": '"production"', + }; + }, + banner: { + js: '"use client";', + }, + splitting: false, + treeshake: true, + // Keep CSS separate + injectStyle: false, + // Don't bundle CSS with JS + onSuccess: + 'echo "✅ TypeScript library built successfully with declarations!"', +}); diff --git a/packages/ui-kit/vite.config.ts b/packages/ui-kit/vite.config.ts index 38b9bd4..abbbec7 100644 --- a/packages/ui-kit/vite.config.ts +++ b/packages/ui-kit/vite.config.ts @@ -1,33 +1,36 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' -import { resolve } from 'path' +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; +import { resolve } from "path"; export default defineConfig({ - plugins: [ - react({ - jsxRuntime: 'automatic', - jsxImportSource: 'react', - }) - ], - resolve: { - alias: { - '@': resolve(__dirname, './src') - } + plugins: [ + react({ + jsxRuntime: "automatic", + jsxImportSource: "react", + }), + ], + resolve: { + alias: { + "@": resolve(__dirname, "./src"), }, - build: { - lib: { - entry: resolve(__dirname, 'src/index.ts'), - name: 'UIKit', - fileName: 'ui-kit' + }, + build: { + lib: { + entry: resolve(__dirname, "src/index.ts"), + name: "UIKit", + fileName: "ui-kit", + }, + rollupOptions: { + external: ["react", "react-dom"], + output: { + globals: { + react: "React", + "react-dom": "ReactDOM", }, - rollupOptions: { - external: ['react', 'react-dom'], - output: { - globals: { - react: 'React', - 'react-dom': 'ReactDOM' - } - } - } - } -}) \ No newline at end of file + }, + }, + }, + define: { + "process.env.NODE_ENV": '"production"', + }, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6097896..ad84fc1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -114,6 +114,9 @@ importers: tailwindcss: specifier: ^3.4.1 version: 3.4.17 + tsup: + specifier: ^8.5.0 + version: 8.5.0(@swc/core@1.11.24)(jiti@2.4.2)(postcss@8.5.3)(tsx@4.19.4)(typescript@5.8.3)(yaml@2.8.0) typescript: specifier: ^5.8.3 version: 5.8.3 @@ -511,6 +514,9 @@ importers: tailwindcss: specifier: ^3.4.17 version: 3.4.17 + tsup: + specifier: ^8.5.0 + version: 8.5.0(@swc/core@1.11.24)(jiti@2.4.2)(postcss@8.5.3)(tsx@4.19.4)(typescript@5.8.3)(yaml@2.8.0) typescript-eslint: specifier: ^8.32.1 version: 8.32.1(eslint@9.27.0(jiti@2.4.2))(typescript@5.8.3) @@ -3474,6 +3480,12 @@ packages: buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + bundle-require@5.1.0: + resolution: {integrity: sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + peerDependencies: + esbuild: '>=0.18' + bytes-iec@3.1.1: resolution: {integrity: sha512-fey6+4jDK7TFtFg/klGSvNKJctyU7n2aQdnM+CO0ruLPbqqMOM8Tio0Pc+deqUeVKX1tL5DQep1zQ7+37aTAsA==} engines: {node: '>= 0.8'} @@ -4359,6 +4371,9 @@ packages: resolution: {integrity: sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g==} engines: {node: '>=18'} + fix-dts-default-cjs-exports@1.0.1: + resolution: {integrity: sha512-pVIECanWFC61Hzl2+oOCtoJ3F17kglZC/6N94eRWycFgBH35hHx0Li604ZIzhseh97mf2p0cv7vVrOZGoqhlEg==} + flat-cache@4.0.1: resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} engines: {node: '>=16'} @@ -5140,6 +5155,10 @@ packages: joi@17.13.3: resolution: {integrity: sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==} + joycon@3.1.1: + resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} + engines: {node: '>=10'} + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -5288,6 +5307,10 @@ packages: resolution: {integrity: sha512-LWzX2KsqcB1wqQ4AHgYb4RsDXauQiqhjLk+6hjbaeHG4zpjjVAB6wC/gz6X0l+Du1cN3pUB5ZlrvTbhGSNnUQQ==} engines: {node: '>=18.0.0'} + load-tsconfig@0.2.5: + resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + local-pkg@0.5.1: resolution: {integrity: sha512-9rrA30MRRP3gBD3HTGnC6cDFpaE1kVDWxWgqWJUN0RvDNAo+Nz/9GxB+nHOH0ifbVFy0hSA1V6vFDvnx54lTEQ==} engines: {node: '>=14'} @@ -5335,6 +5358,9 @@ packages: lodash.snakecase@4.1.1: resolution: {integrity: sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==} + lodash.sortby@4.7.0: + resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==} + lodash.startcase@4.4.0: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} @@ -5889,6 +5915,24 @@ packages: ts-node: optional: true + postcss-load-config@6.0.1: + resolution: {integrity: sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==} + engines: {node: '>= 18'} + peerDependencies: + jiti: '>=1.21.0' + postcss: '>=8.0.9' + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + jiti: + optional: true + postcss: + optional: true + tsx: + optional: true + yaml: + optional: true + postcss-nested@6.2.0: resolution: {integrity: sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==} engines: {node: '>=12.0'} @@ -6374,6 +6418,10 @@ packages: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + source-map@0.8.0-beta.0: + resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==} + engines: {node: '>= 8'} + spawn-wrap@2.0.0: resolution: {integrity: sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==} engines: {node: '>=8'} @@ -6642,6 +6690,9 @@ packages: resolution: {integrity: sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==} engines: {node: '>=16'} + tr46@1.0.1: + resolution: {integrity: sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==} + tr46@5.1.1: resolution: {integrity: sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==} engines: {node: '>=18'} @@ -6677,6 +6728,25 @@ packages: resolution: {integrity: sha512-oDWuGVONxhVEBtschLf2cs/Jy8i7h1T+CpdkTNWQgdAF7DhRo2G8vMCgILKe7ojdEkLhICWgI1LYSSKaJsRgcw==} engines: {node: '>=16'} + tsup@8.5.0: + resolution: {integrity: sha512-VmBp77lWNQq6PfuMqCHD3xWl22vEoWsKajkF8t+yMBawlUS8JzEI+vOVMeuNZIuMML8qXRizFKi9oD5glKQVcQ==} + engines: {node: '>=18'} + hasBin: true + peerDependencies: + '@microsoft/api-extractor': ^7.36.0 + '@swc/core': ^1 + postcss: ^8.4.12 + typescript: '>=4.5.0' + peerDependenciesMeta: + '@microsoft/api-extractor': + optional: true + '@swc/core': + optional: true + postcss: + optional: true + typescript: + optional: true + tsx@4.19.4: resolution: {integrity: sha512-gK5GVzDkJK1SI1zwHf32Mqxf2tSJkNx+eYcNly5+nHvWqXUJYUkWBQtKauoESz3ymezAI++ZwT855x5p5eop+Q==} engines: {node: '>=18.0.0'} @@ -6981,6 +7051,9 @@ packages: walker@1.0.8: resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} + webidl-conversions@4.0.2: + resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} + webidl-conversions@7.0.0: resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==} engines: {node: '>=12'} @@ -7000,6 +7073,9 @@ packages: resolution: {integrity: sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==} engines: {node: '>=18'} + whatwg-url@7.1.0: + resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==} + which-boxed-primitive@1.1.1: resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==} engines: {node: '>= 0.4'} @@ -10656,6 +10732,11 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 + bundle-require@5.1.0(esbuild@0.25.4): + dependencies: + esbuild: 0.25.4 + load-tsconfig: 0.2.5 + bytes-iec@3.1.1: {} c8@7.14.0: @@ -11734,6 +11815,12 @@ snapshots: path-exists: 5.0.0 unicorn-magic: 0.1.0 + fix-dts-default-cjs-exports@1.0.1: + dependencies: + magic-string: 0.30.17 + mlly: 1.7.4 + rollup: 4.41.0 + flat-cache@4.0.1: dependencies: flatted: 3.3.3 @@ -12749,6 +12836,8 @@ snapshots: '@sideway/formula': 3.0.1 '@sideway/pinpoint': 2.0.0 + joycon@3.1.1: {} + js-tokens@4.0.0: {} js-tokens@9.0.1: {} @@ -12932,6 +13021,8 @@ snapshots: rfdc: 1.4.1 wrap-ansi: 9.0.0 + load-tsconfig@0.2.5: {} + local-pkg@0.5.1: dependencies: mlly: 1.7.4 @@ -12972,6 +13063,8 @@ snapshots: lodash.snakecase@4.1.1: {} + lodash.sortby@4.7.0: {} + lodash.startcase@4.4.0: {} lodash.uniq@4.5.0: {} @@ -13486,6 +13579,15 @@ snapshots: optionalDependencies: postcss: 8.5.3 + postcss-load-config@6.0.1(jiti@2.4.2)(postcss@8.5.3)(tsx@4.19.4)(yaml@2.8.0): + dependencies: + lilconfig: 3.1.3 + optionalDependencies: + jiti: 2.4.2 + postcss: 8.5.3 + tsx: 4.19.4 + yaml: 2.8.0 + postcss-nested@6.2.0(postcss@8.5.3): dependencies: postcss: 8.5.3 @@ -14002,6 +14104,10 @@ snapshots: source-map@0.6.1: {} + source-map@0.8.0-beta.0: + dependencies: + whatwg-url: 7.1.0 + spawn-wrap@2.0.0: dependencies: foreground-child: 2.0.0 @@ -14312,6 +14418,10 @@ snapshots: dependencies: tldts: 6.1.86 + tr46@1.0.1: + dependencies: + punycode: 2.3.1 + tr46@5.1.1: dependencies: punycode: 2.3.1 @@ -14340,6 +14450,35 @@ snapshots: tslog@4.9.3: {} + tsup@8.5.0(@swc/core@1.11.24)(jiti@2.4.2)(postcss@8.5.3)(tsx@4.19.4)(typescript@5.8.3)(yaml@2.8.0): + dependencies: + bundle-require: 5.1.0(esbuild@0.25.4) + cac: 6.7.14 + chokidar: 4.0.3 + consola: 3.4.2 + debug: 4.4.1(supports-color@8.1.1) + esbuild: 0.25.4 + fix-dts-default-cjs-exports: 1.0.1 + joycon: 3.1.1 + picocolors: 1.1.1 + postcss-load-config: 6.0.1(jiti@2.4.2)(postcss@8.5.3)(tsx@4.19.4)(yaml@2.8.0) + resolve-from: 5.0.0 + rollup: 4.41.0 + source-map: 0.8.0-beta.0 + sucrase: 3.35.0 + tinyexec: 0.3.2 + tinyglobby: 0.2.13 + tree-kill: 1.2.2 + optionalDependencies: + '@swc/core': 1.11.24 + postcss: 8.5.3 + typescript: 5.8.3 + transitivePeerDependencies: + - jiti + - supports-color + - tsx + - yaml + tsx@4.19.4: dependencies: esbuild: 0.25.4 @@ -14671,6 +14810,8 @@ snapshots: dependencies: makeerror: 1.0.12 + webidl-conversions@4.0.2: {} + webidl-conversions@7.0.0: {} webpack-virtual-modules@0.6.2: {} @@ -14686,6 +14827,12 @@ snapshots: tr46: 5.1.1 webidl-conversions: 7.0.0 + whatwg-url@7.1.0: + dependencies: + lodash.sortby: 4.7.0 + tr46: 1.0.1 + webidl-conversions: 4.0.2 + which-boxed-primitive@1.1.1: dependencies: is-bigint: 1.1.0