diff --git a/build.config.ts b/build.config.ts deleted file mode 100644 index c085f46..0000000 --- a/build.config.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { defineBuildConfig } from 'unbuild' - -export default defineBuildConfig({ - entries: [ - 'src/index', - 'src/cli', - ], - declaration: 'node16', - clean: true, - rollup: { - inlineDependencies: [ - '@fast-csv/parse', - 'd3-hierarchy', - '@antfu/utils', - 'normalize-url', - 'p-limit', - 'yocto-queue', - 'lodash.escaperegexp', - 'lodash.isnil', - 'lodash.isfunction', - 'lodash.isundefined', - 'lodash.uniq', - 'lodash.groupby', - ], - }, -}) diff --git a/package.json b/package.json index a722e00..a1c6f23 100644 --- a/package.json +++ b/package.json @@ -34,16 +34,13 @@ "dist" ], "scripts": { - "build": "unbuild", - "stub": "unbuild --stub", + "build": "vite build", "dev": "esno src/cli.ts", "test": "npm-run-all test:unit test:report test:lint", "test:unit": "jest --coverage", "test:report": "jest --reporters=jest-junit", "test:lint": "eslint .", - "typecheck": "tsc --noEmit", - "prepublishOnly": "nr build", - "release": "bumpp && pnpm publish" + "typecheck": "tsc --noEmit" }, "dependencies": { "@crowdin/crowdin-api-client": "^1.41.2", @@ -60,11 +57,12 @@ "@antfu/utils": "^9.1.0", "@babel/core": "7.26.9", "@babel/preset-env": "7.26.9", - "@codecov/webpack-plugin": "1.9.0", + "@codecov/vite-plugin": "1.9.0", "@fast-csv/parse": "^5.0.2", + "@rollup/plugin-commonjs": "28.0.3", + "@rollup/plugin-node-resolve": "16.0.1", "@types/d3-hierarchy": "^3.1.7", "@types/node": "^22.13.10", - "bumpp": "^10.0.3", "d3-hierarchy": "^3.1.2", "eslint": "^9.22.0", "eslint-plugin-jest": "28.11.0", @@ -78,7 +76,8 @@ "p-limit": "^6.2.0", "tsx": "^4.19.3", "typescript": "^5.8.2", - "unbuild": "^3.5.0" + "vite": "6.3.4", + "vite-plugin-dts": "4.5.3" }, "jest": { "collectCoverageFrom": [ diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..383090c --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,67 @@ +import { defineConfig } from 'vite' +import { resolve } from 'path' +import dts from 'vite-plugin-dts' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' +import ts from 'typescript' +import { codecovVitePlugin } from "@codecov/vite-plugin"; + +export default defineConfig({ + build: { + lib: { + entry: { + index: resolve(__dirname, 'src/index.ts'), + cli: resolve(__dirname, 'src/cli.ts') + }, + formats: ['es'], + fileName: (format, entryName) => `${entryName}.mjs` + }, + rollupOptions: { + external: [ + /node:.*/, + '@crowdin/crowdin-api-client', + '@fast-csv/parse', + 'ansis', + 'cac', + 'consola', + 'dotenv', + 'fs', + 'normalize-url', + 'ofetch', + 'p-limit', + 'sharp', + 'stream', + 'string_decoder', + 'unconfig' + ], + plugins: [ + nodeResolve({ + preferBuiltins: true + }), + commonjs() + ] + }, + emptyOutDir: true, + }, + plugins: [ + dts({ + tsconfigPath: './tsconfig.json', + compilerOptions: { + moduleResolution: ts.ModuleResolutionKind.NodeJs, + target: ts.ScriptTarget.ESNext, + }, + exclude: ['example/**/*'], + }), + // The Codecov vite plugin should be after all other plugins + codecovVitePlugin({ + enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined, + bundleName: "contribkit", + uploadToken: process.env.CODECOV_TOKEN, + }), + ], + resolve: { + alias: { + 'contribkit': resolve(__dirname, './src/index.ts'), + } + } +})