Skip to content

Commit 462e4f0

Browse files
authored
Migrate to tsup (#30)
1 parent e4d844c commit 462e4f0

File tree

5 files changed

+891
-3140
lines changed

5 files changed

+891
-3140
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.eslintrc.js
22
dist/
3+
tsup.config.ts
34
vite.config.mts
45
vitest-setup.ts
56
website/

package.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swan-io/use-form",
3-
"version": "2.0.0-rc.2",
3+
"version": "2.0.0",
44
"license": "MIT",
55
"description": "A simple, fast and opinionated form library for React & React Native focusing on UX.",
66
"author": "Mathieu Acthernoene <[email protected]>",
@@ -33,20 +33,14 @@
3333
"registry": "https://registry.npmjs.org"
3434
},
3535
"scripts": {
36-
"clean": "rm -rf dist",
3736
"format": "prettier '**/*' --ignore-unknown --write",
3837
"lint": "eslint --ext ts,tsx __tests__ src",
3938
"test": "vitest --run",
4039
"test:watch": "vitest --watch",
4140
"typecheck": "tsc --noEmit",
42-
"build": "yarn clean && microbundle -f cjs,es --tsconfig tsconfig.build.json",
41+
"build": "tsup",
4342
"prepack": "yarn typecheck && yarn lint && yarn test && yarn build"
4443
},
45-
"browserslist": [
46-
">0.2%",
47-
"not op_mini all",
48-
"not dead"
49-
],
5044
"prettier": {
5145
"printWidth": 100,
5246
"plugins": [
@@ -61,17 +55,18 @@
6155
},
6256
"devDependencies": {
6357
"@testing-library/react": "^14.2.1",
58+
"@types/node": "^20.12.3",
6459
"@types/react": "^18.2.63",
6560
"@typescript-eslint/eslint-plugin": "^7.1.1",
6661
"@typescript-eslint/parser": "^7.1.1",
6762
"eslint": "^8.57.0",
6863
"eslint-plugin-react-hooks": "^4.6.0",
6964
"jsdom": "^24.0.0",
70-
"microbundle": "^0.15.1",
7165
"prettier": "^3.2.5",
7266
"prettier-plugin-organize-imports": "^3.2.4",
7367
"react": "^18.2.0",
7468
"react-dom": "^18.2.0",
69+
"tsup": "^8.0.2",
7570
"typescript": "^5.3.3",
7671
"vitest": "^1.3.1"
7772
}

tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
"include": ["src", "__tests__"],
33
"compilerOptions": {
44
"module": "ESNext",
5-
"target": "ES2018",
6-
"lib": ["DOM", "DOM.Iterable", "ES2018"],
5+
"target": "ES2019",
6+
"lib": ["DOM", "DOM.Iterable", "ES2019"],
77
"jsx": "react",
88
"moduleResolution": "Node",
9-
"outDir": "dist/",
109

1110
"allowJs": false,
1211
"declaration": true,

tsup.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Options, defineConfig } from "tsup";
2+
3+
const commonOptions: Partial<Options> = {
4+
entry: { index: "src/index.ts" },
5+
tsconfig: "./tsconfig.build.json",
6+
target: "es2019",
7+
sourcemap: true,
8+
treeshake: true,
9+
};
10+
11+
export default defineConfig([
12+
{
13+
...commonOptions,
14+
clean: true,
15+
format: "esm",
16+
},
17+
{
18+
...commonOptions,
19+
dts: true,
20+
format: "cjs",
21+
},
22+
]);

0 commit comments

Comments
 (0)