From 7e394864c5bec1c34cead0037baad6014d5d6fe7 Mon Sep 17 00:00:00 2001 From: Hussein Martinez Date: Fri, 18 Oct 2024 17:43:18 +0700 Subject: [PATCH] fix: build --- lib/examples/index.ts | 2 ++ package.json | 8 ++++---- vite.config.ts | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 lib/examples/index.ts diff --git a/lib/examples/index.ts b/lib/examples/index.ts new file mode 100644 index 0000000..ad60cb6 --- /dev/null +++ b/lib/examples/index.ts @@ -0,0 +1,2 @@ +export { Button } from "./button"; +export { Callout } from "./callout"; diff --git a/package.json b/package.json index 89571da..d8fb808 100644 --- a/package.json +++ b/package.json @@ -3,16 +3,16 @@ "version": "0.0.0", "type": "module", "types": "./dist/index.d.ts", - "main": "./dist/index.umd.ts", - "module": "./dist/index.es.ts", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", "files": [ "dist" ], "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.es.ts", - "require": "./dist/index.umd.ts" + "import": "./dist/index.mjs", + "require": "./dist/index.cjs" } }, "scripts": { diff --git a/vite.config.ts b/vite.config.ts index 281d365..8a4f2d1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,7 +11,11 @@ export default defineConfig({ lib: { entry: resolve(__dirname, "./lib/index.ts"), name: "gitcoin-ui", - fileName: (format) => `index.${format}.js`, + fileName: (format, filename) => { + const extension = format === "es" ? "mjs" : format; + return `${filename}.${extension}`; + }, + formats: ["cjs", "es"], }, rollupOptions: { external: ["react", "react-dom", "tailwindcss"], @@ -21,6 +25,7 @@ export default defineConfig({ "react-dom": "ReactDOM", tailwindcss: "tailwindcss", }, + preserveModules: true, }, }, sourcemap: true,