Skip to content

Commit

Permalink
fix: lib build
Browse files Browse the repository at this point in the history
  • Loading branch information
timhettler committed Dec 11, 2024
1 parent 058850e commit a388fdc
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 580 deletions.
4 changes: 2 additions & 2 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@radix-ui/react-primitive": "^2.0.0"
},
"devDependencies": {
"@rollup/plugin-typescript": "^12.1.1",
"@types/react": "^18.3.14",
"@types/react-dom": "^18.3.3",
"@typescript-eslint/eslint-plugin": "^8.18.0",
Expand All @@ -47,8 +48,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-plugin-dts": "^4.3.0"
"vite": "^6.0.3"
},
"peerDependencies": {
"react": "*",
Expand Down
5 changes: 2 additions & 3 deletions lib/src/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useComposedRefs } from "@radix-ui/react-compose-refs";
import { createContextScope } from "@radix-ui/react-context";
import { Primitive } from "@radix-ui/react-primitive";

import type * as Radix from "@radix-ui/react-primitive";
import type { Scope } from "@radix-ui/react-context";

import { useRedundantClick } from "./useRedundantClick";
Expand All @@ -27,7 +26,7 @@ const [CardProvider, useCardContext] =
createCardContext<CardContextValue>(CARD_NAME);

type CardElement = React.ElementRef<typeof Primitive.div>;
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
type PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
interface CardProps extends PrimitiveDivProps {}

const Card = React.forwardRef<CardElement, CardProps>(
Expand Down Expand Up @@ -77,7 +76,7 @@ Card.displayName = CARD_NAME;
const TARGET_NAME = "CardTarget";

type CardTargetElement = React.ElementRef<typeof Primitive.a>;
type PrimitiveAnchorProps = Radix.ComponentPropsWithoutRef<typeof Primitive.a>;
type PrimitiveAnchorProps = React.ComponentPropsWithoutRef<typeof Primitive.a>;
interface CardTargetProps extends PrimitiveAnchorProps {}

const CardTarget = React.forwardRef<CardTargetElement, CardTargetProps>(
Expand Down
21 changes: 13 additions & 8 deletions lib/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import { resolve } from "path";
import path from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import dts from "vite-plugin-dts";
import typescript from "@rollup/plugin-typescript";

const resolvePath = (str: string) => path.resolve(__dirname, str);

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), dts({ copyDtsFiles: false, rollupTypes: true })],
plugins: [
react(),
typescript({
tsconfig: resolvePath("tsconfig.app.json"),
declaration: true,
declarationDir: resolvePath("dist"),
}),
],
build: {
lib: {
entry: resolve(__dirname, "src/main.ts"),
entry: resolvePath("src/main.ts"),
formats: ["es"],
},
rollupOptions: {
external: ["react", "react-dom"],
input: [resolve(__dirname, "src/main.ts")],
output: {
preserveModules: false,
},
},
},
});
Loading

0 comments on commit a388fdc

Please sign in to comment.