Skip to content

Commit

Permalink
fix(build): use vite to emit cjs and esm formats
Browse files Browse the repository at this point in the history
  • Loading branch information
manbearwiz authored Jul 22, 2024
1 parent a2405c4 commit c1e51aa
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 deletions.
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "vitest-tiny-reporter",
"version": "0.0.0-development",
"description": "Tiny reporter for vitest",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["/dist"],
"types": "dist/types/index.d.ts",
"files": ["dist"],
"keywords": ["vitest", "reporter", "lefthook"],
"scripts": {
"build": "tsc",
"build": "npx concurrently npm:build:*",
"build:vite": "vite build",
"build:tsc": "tsc -b tsconfig.types.json",
"test": "vitest run",
"coverage": "vitest run --coverage",
"test:watch": "vitest --watch --coverage --ui",
Expand All @@ -32,12 +33,14 @@
"@commitlint/config-angular": "^19.3.0",
"@tsconfig/recommended": "^1.0.3",
"@tsconfig/strictest": "^2.0.2",
"@tsconfig/vite-react": "^3.0.2",
"@types/node": "^20.12.12",
"@vitest/coverage-v8": "^2.0.3",
"@vitest/ui": "^2.0.3",
"happy-dom": "^14.12.3",
"semantic-release": "^22.0.0",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"vite": "^5.3.4"
},
"dependencies": {
"@vitest/runner": "^2.0.3",
Expand All @@ -46,5 +49,15 @@
},
"release": {
"branches": ["main"]
},
"type": "module",
"main": "./dist/vitest-tiny-reporter.umd.cjs",
"module": "./dist/vitest-tiny-reporter.js",
"exports": {
".": {
"import": "./dist/vitest-tiny-reporter.js",
"require": "./dist/vitest-tiny-reporter.umd.cjs",
"types": "./dist/types/index.d.ts"
}
}
}
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/recommended/tsconfig"],
"extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/vite-react/tsconfig"],
"compilerOptions": {
"declaration": true,
"outDir": "./dist"
},
"files": ["src/index.ts"]
"files": ["src/index.ts"],
"exclude": ["src/**/*.test*"]
}
10 changes: 10 additions & 0 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "dist/types",
"emitDeclarationOnly": true,
"noEmit": false
}
}
18 changes: 17 additions & 1 deletion vitest.config.mts → vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import type { UserConfig } from 'vitest/config';

export default {
build: {
emptyOutDir: false,
lib: {
entry: 'src/index.ts',
name: 'vitest-tiny-reporter',
},
rollupOptions: {
external: ['tinyrainbow'],
output: {
globals: {
tinyrainbow: 'tinyrainbow',
},
},
},
sourcemap: true,
},
test: {
environment: 'happy-dom',
coverage: {
reporter: ['cobertura', 'text', 'html', 'lcov'],
thresholds: {
statements: 93.75,
branches: 82.14,
branches: 82.75,
functions: 100,
lines: 93.75,
autoUpdate: true,
Expand Down

0 comments on commit c1e51aa

Please sign in to comment.