Skip to content

Commit a0dfd0f

Browse files
authored
feat!: improve build with vite
1 parent bc6ff8d commit a0dfd0f

File tree

7 files changed

+758
-196
lines changed

7 files changed

+758
-196
lines changed

components/AriaTable/AriaTable.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { Image } from '../Image';
99
import { UnstyledLink } from '../Link';
1010
import { Text } from '../Text';
1111
import {
12+
AriaTableProps,
13+
AriaTableVariants,
1214
Caption,
1315
Table,
14-
TableProps,
15-
TableVariants,
1616
Tbody,
1717
Td,
1818
Tfoot,
@@ -21,8 +21,8 @@ import {
2121
Tr,
2222
} from './AriaTable';
2323

24-
const BaseTable = (props: TableProps): JSX.Element => <Table {...props} />;
25-
const TableForStory = modifyVariantsForStory<TableVariants, TableProps>(BaseTable);
24+
const BaseTable = (props: AriaTableProps): JSX.Element => <Table {...props} />;
25+
const TableForStory = modifyVariantsForStory<AriaTableVariants, AriaTableProps>(BaseTable);
2626

2727
const Component: Meta<typeof TableForStory> = {
2828
title: 'Components/AriaTable',

components/AriaTable/AriaTable.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import React, {
1515

1616
import { styled, VariantProps } from '../../stitches.config';
1717
import { Box } from '../Box';
18+
import type { TableVariants } from '../Table';
1819
import {
1920
Caption as TableCaption,
2021
StyledTr as TableTr,
@@ -98,15 +99,16 @@ const AnimatedContainer = ({ isOpen, children }: { isOpen: boolean; children: Re
9899
);
99100
};
100101

101-
export type TrProps = ComponentProps<typeof StyledTr> &
102+
export type AriaTrProps = ComponentProps<typeof StyledTr> &
102103
VariantProps<typeof StyledTr> & {
103104
asChild?: boolean;
104105
collapsedContent?: React.ReactNode;
105106
emptyFirstColumn?: boolean;
106107
tableHead?: boolean;
108+
children?: React.ReactNode;
107109
};
108110

109-
export const Tr = forwardRef<ElementRef<typeof StyledTr>, TrProps>(
111+
export const Tr = forwardRef<ElementRef<typeof StyledTr>, AriaTrProps>(
110112
({ asChild, children, collapsedContent, emptyFirstColumn, tableHead, css, ...props }, ref) => {
111113
const Component = asChild ? StyledTrSlot : StyledTr;
112114
const [isCollapsed, setIsCollapsed] = useState(false);
@@ -275,5 +277,5 @@ export const Table = forwardRef<
275277
/>
276278
));
277279

278-
export type TableVariants = VariantProps<typeof Table>;
279-
export type TableProps = TableVariants & NonNullable<unknown>;
280+
export type AriaTableVariants = VariantProps<typeof Table>;
281+
export type AriaTableProps = TableVariants & NonNullable<unknown>;

package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"scripts": {
3434
"prettier": "prettier --write .",
35-
"build": "rollup -c",
35+
"build": "vite build",
3636
"lint": "eslint \"./components/**/*.{ts,tsx}\"",
3737
"lint:fix": "eslint --fix \"./components/**/*.{ts,tsx}\"",
3838
"release": "yarn build && np",
@@ -85,13 +85,11 @@
8585
"@radix-ui/react-use-layout-effect": "^1.0.0",
8686
"@radix-ui/react-visually-hidden": "^1.0.1",
8787
"@rehookify/datepicker": "^6.6.7",
88-
"@rollup/plugin-babel": "^5.3.1",
8988
"@semantic-release/commit-analyzer": "^9.0.2",
9089
"@semantic-release/github": "^8.0.2",
9190
"@semantic-release/npm": "^9.0.0",
9291
"@semantic-release/release-notes-generator": "^10.0.3",
93-
"@stitches/react": "1.2.7",
94-
"@storybook/addon-actions": "^8.2.2",
92+
"@stitches/react": "1.2.8",
9593
"@storybook/addon-docs": "^8.2.5",
9694
"@storybook/addon-essentials": "^8.2.5",
9795
"@storybook/addon-links": "^8.2.2",
@@ -120,13 +118,11 @@
120118
"prettier": "^3.3.3",
121119
"react": "18.2.0",
122120
"react-dom": "18.2.0",
123-
"rollup": "^2.70.1",
124-
"rollup-plugin-typescript2": "^0.36.0",
125121
"semantic-release": "^19.0.2",
126122
"storybook": "^8.2.5",
127123
"storybook-dark-mode": "^4.0.2",
128124
"tinycolor2": "^1.4.2",
129-
"typescript": "5.4.5",
125+
"typescript": "^5.8.3",
130126
"use-debounce": "9.0.2",
131127
"vite": "^5.1.5"
132128
},
@@ -148,6 +144,7 @@
148144
"jest": "^27.5.1",
149145
"jest-axe": "^6.0.0",
150146
"typescript-eslint": "^8.11.0",
147+
"vite-plugin-dts": "^4.5.4",
151148
"webpack": "^5.94.0"
152149
},
153150
"publishConfig": {
@@ -180,7 +177,7 @@
180177
]
181178
},
182179
"engines": {
183-
"node": ">=18.12.1"
180+
"node": ">=20.0.0"
184181
},
185-
"packageManager": "yarn@4.4.0"
182+
"packageManager": "yarn@4.9.1"
186183
}

rollup.config.js

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
"react": ["./node_modules/@types/react"]
2626
}
2727
},
28-
"exclude": ["node_modules", "pages", "**/*.test.tsx"],
28+
"exclude": [
29+
"node_modules",
30+
"pages",
31+
"**/*.test.tsx",
32+
"**/*.test.ts",
33+
"**/*.stories.tsx",
34+
"**/*.stories.ts",
35+
"stories"
36+
],
2937
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
3038
}

vite.config.ts

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,53 @@
11
import react from '@vitejs/plugin-react';
2+
import { createRequire } from 'module';
23
import { defineConfig } from 'vite';
4+
import dts from 'vite-plugin-dts';
5+
6+
const require = createRequire(import.meta.url);
7+
const pkg = require('./package.json');
38

49
export default defineConfig({
5-
optimizeDeps: {
6-
exclude: ['storybook'],
10+
plugins: [
11+
react(),
12+
dts({
13+
tsconfigPath: 'tsconfig-build.json',
14+
outDir: 'dist',
15+
insertTypesEntry: true,
16+
cleanVueFileName: true,
17+
exclude: [
18+
'**/*.stories.tsx',
19+
'**/*.stories.ts',
20+
'**/*.test.tsx',
21+
'**/*.test.ts',
22+
'stories/**',
23+
],
24+
}),
25+
],
26+
build: {
27+
lib: {
28+
entry: './index.ts',
29+
name: 'Faency',
30+
formats: ['es', 'cjs'],
31+
fileName: (format, entryName) => `${entryName}.${format === 'es' ? 'js' : 'cjs'}`,
32+
},
33+
rollupOptions: {
34+
external: [
35+
'react/jsx-runtime',
36+
...Object.keys(pkg.dependencies || {}),
37+
...Object.keys(pkg.peerDependencies || {}),
38+
],
39+
output: {
40+
globals: {
41+
react: 'React',
42+
'react-dom': 'ReactDOM',
43+
},
44+
preserveModules: true,
45+
preserveModulesRoot: '.',
46+
},
47+
},
48+
outDir: 'dist',
49+
emptyOutDir: true,
50+
sourcemap: true,
51+
minify: false,
752
},
8-
plugins: [react()],
953
});

0 commit comments

Comments
 (0)