Skip to content

Commit 7835f41

Browse files
authored
chore: use tsup insead of rollup (#320)
1 parent 187864d commit 7835f41

File tree

4 files changed

+440
-262
lines changed

4 files changed

+440
-262
lines changed

examples/nextjs/next.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { build } from 'velite'
2-
31
import type { NextConfig } from 'next'
42

53
const isDev = process.argv.indexOf('dev') !== -1
64
const isBuild = process.argv.indexOf('build') !== -1
75
if (!process.env.VELITE_STARTED && (isDev || isBuild)) {
86
process.env.VELITE_STARTED = '1'
9-
build({ watch: isDev, clean: !isDev })
7+
import('velite').then(m => m.build({ watch: isDev, clean: !isDev }))
108
}
119

1210
const nextConfig: NextConfig = {

package.json

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,47 @@
1616
"license": "MIT",
1717
"author": "zce <w@zce.me> (https://zce.me)",
1818
"type": "module",
19-
"main": "./dist/index.js",
20-
"exports": "./dist/index.js",
21-
"types": "./dist/index.d.ts",
2219
"bin": "./bin/velite.js",
20+
"main": "./dist/index.cjs",
21+
"module": "./dist/index.js",
22+
"types": "./dist/index.d.ts",
23+
"exports": {
24+
"./package.json": "./package.json",
25+
".": {
26+
"import": "./dist/index.js",
27+
"require": "./dist/index.cjs"
28+
}
29+
},
2330
"files": [
2431
"dist"
2532
],
2633
"scripts": {
27-
"build": "tsc && rollup -c",
34+
"build": "tsc && tsup",
2835
"test": "node --import tsx --test test/*.ts",
2936
"docs:dev": "cd docs && pnpm dev",
3037
"docs:build": "cd docs && pnpm build",
3138
"format": "prettier . --write"
3239
},
40+
"tsup": {
41+
"entry": [
42+
"src/index.ts",
43+
"src/cli.ts"
44+
],
45+
"format": [
46+
"esm",
47+
"cjs"
48+
],
49+
"platform": "node",
50+
"target": "node18",
51+
"banner": {
52+
"js": "import {createRequire as __createRequire} from 'module';const require=__createRequire(import.meta.url);"
53+
},
54+
"dts": {
55+
"resolve": true
56+
},
57+
"treeshake": true,
58+
"clean": true
59+
},
3360
"prettier": "@zce/prettier-config",
3461
"simple-git-hooks": {
3562
"pre-commit": "pnpm lint-staged"
@@ -44,9 +71,6 @@
4471
"terser": "^5.39.2"
4572
},
4673
"devDependencies": {
47-
"@rollup/plugin-commonjs": "^28.0.3",
48-
"@rollup/plugin-json": "^6.1.0",
49-
"@rollup/plugin-node-resolve": "^16.0.1",
5074
"@types/hast": "^3.0.4",
5175
"@types/mdast": "^4.0.4",
5276
"@types/node": "^22.15.19",
@@ -67,10 +91,8 @@
6791
"remark-gfm": "^4.0.1",
6892
"remark-parse": "^11.0.0",
6993
"remark-rehype": "^11.1.2",
70-
"rollup": "^4.41.0",
71-
"rollup-plugin-dts": "^6.2.1",
72-
"rollup-plugin-esbuild": "^6.2.1",
7394
"simple-git-hooks": "^2.13.0",
95+
"tsup": "^8.5.0",
7496
"tsx": "^4.19.4",
7597
"typescript": "^5.8.3",
7698
"unified": "^11.0.5",

0 commit comments

Comments
 (0)