Skip to content

Commit bb94aa2

Browse files
build: change build system to vite and add codecov bundle analysis
1 parent 2dbc5db commit bb94aa2

File tree

3 files changed

+74
-34
lines changed

3 files changed

+74
-34
lines changed

build.config.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@
3434
"dist"
3535
],
3636
"scripts": {
37-
"build": "unbuild",
38-
"stub": "unbuild --stub",
37+
"build": "vite build",
3938
"dev": "esno src/cli.ts",
4039
"test": "npm-run-all test:unit test:report test:lint",
4140
"test:unit": "jest --coverage",
4241
"test:report": "jest --reporters=jest-junit",
4342
"test:lint": "eslint .",
44-
"typecheck": "tsc --noEmit",
45-
"prepublishOnly": "nr build",
46-
"release": "bumpp && pnpm publish"
43+
"typecheck": "tsc --noEmit"
4744
},
4845
"dependencies": {
4946
"@crowdin/crowdin-api-client": "^1.41.2",
@@ -60,11 +57,12 @@
6057
"@antfu/utils": "^9.1.0",
6158
"@babel/core": "7.26.9",
6259
"@babel/preset-env": "7.26.9",
63-
"@codecov/webpack-plugin": "1.9.0",
60+
"@codecov/vite-plugin": "1.9.0",
6461
"@fast-csv/parse": "^5.0.2",
62+
"@rollup/plugin-commonjs": "28.0.3",
63+
"@rollup/plugin-node-resolve": "16.0.1",
6564
"@types/d3-hierarchy": "^3.1.7",
6665
"@types/node": "^22.13.10",
67-
"bumpp": "^10.0.3",
6866
"d3-hierarchy": "^3.1.2",
6967
"eslint": "^9.22.0",
7068
"eslint-plugin-jest": "28.11.0",
@@ -78,7 +76,8 @@
7876
"p-limit": "^6.2.0",
7977
"tsx": "^4.19.3",
8078
"typescript": "^5.8.2",
81-
"unbuild": "^3.5.0"
79+
"vite": "6.3.4",
80+
"vite-plugin-dts": "4.5.3"
8281
},
8382
"jest": {
8483
"collectCoverageFrom": [

vite.config.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { defineConfig } from 'vite'
2+
import { resolve } from 'path'
3+
import dts from 'vite-plugin-dts'
4+
import { nodeResolve } from '@rollup/plugin-node-resolve'
5+
import commonjs from '@rollup/plugin-commonjs'
6+
import ts from 'typescript'
7+
import { codecovVitePlugin } from "@codecov/vite-plugin";
8+
9+
export default defineConfig({
10+
build: {
11+
lib: {
12+
entry: {
13+
index: resolve(__dirname, 'src/index.ts'),
14+
cli: resolve(__dirname, 'src/cli.ts')
15+
},
16+
formats: ['es'],
17+
fileName: (format, entryName) => `${entryName}.mjs`
18+
},
19+
rollupOptions: {
20+
external: [
21+
/node:.*/,
22+
'@crowdin/crowdin-api-client',
23+
'@fast-csv/parse',
24+
'ansis',
25+
'cac',
26+
'consola',
27+
'dotenv',
28+
'fs',
29+
'normalize-url',
30+
'ofetch',
31+
'p-limit',
32+
'sharp',
33+
'stream',
34+
'string_decoder',
35+
'unconfig'
36+
],
37+
plugins: [
38+
nodeResolve({
39+
preferBuiltins: true
40+
}),
41+
commonjs()
42+
]
43+
},
44+
emptyOutDir: true,
45+
},
46+
plugins: [
47+
dts({
48+
tsconfigPath: './tsconfig.json',
49+
compilerOptions: {
50+
moduleResolution: ts.ModuleResolutionKind.NodeJs,
51+
target: ts.ScriptTarget.ESNext,
52+
},
53+
exclude: ['example/**/*'],
54+
}),
55+
// The Codecov vite plugin should be after all other plugins
56+
codecovVitePlugin({
57+
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
58+
bundleName: "contribkit",
59+
uploadToken: process.env.CODECOV_TOKEN,
60+
}),
61+
],
62+
resolve: {
63+
alias: {
64+
'contribkit': resolve(__dirname, './src/index.ts'),
65+
}
66+
}
67+
})

0 commit comments

Comments
 (0)