Skip to content

Commit

Permalink
Fix build (#14)
Browse files Browse the repository at this point in the history
* Add tsup

* Fix build

* Fix main and module

* Fix checks scripts
  • Loading branch information
bkiac authored Nov 16, 2023
1 parent d65d57b commit d3e7694
Show file tree
Hide file tree
Showing 9 changed files with 557 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- run: pnpm run format:check
- run: pnpm run types
- run: pnpm run ts:check
- run: pnpm run build

test:
needs: check
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
Expand Down
31 changes: 31 additions & 0 deletions cfg/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"skipLibCheck": true,

"moduleDetection": "force",
"isolatedModules": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"moduleResolution": "Bundler",
"module": "ESNext",
"lib": ["ES2022", "DOM", "DOM.Iterable"],

"target": "ES2022",
"noEmit": true,

"strict": true,
"forceConsistentCasingInFileNames": true,
"allowUnusedLabels": false,
"allowUnreachableCode": false,
// "exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": ["../src"],
"exclude": ["../node_modules", "../lib", "../**/*.ignore.ts"]
}
11 changes: 11 additions & 0 deletions cfg/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"noEmit": false,
"outDir": "../lib",
"declaration": true,
"emitDeclarationOnly": true,
"removeComments": false
},
"exclude": ["../node_modules", "../**/*.ignore.ts", "../**/*.test.ts"]
}
25 changes: 25 additions & 0 deletions cfg/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {defineConfig} from "tsup"

export default defineConfig({
bundle: true,
clean: true,
dts: false,
entry: ["src/index.ts", "src/internal.ts"],
format: ["esm", "cjs"],
keepNames: true,
minify: false,
outDir: "lib",
outExtension({format}) {
if (format === "iife") {
throw new Error("iife is not supported")
}
return {
js: format === "cjs" ? `.${format}` : ".js",
}
},
platform: "neutral",
sourcemap: false,
splitting: true,
target: "es2022",
treeshake: true,
})
File renamed without changes.
24 changes: 18 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@
"name": "ruts",
"version": "0.9.0",
"type": "module",
"description": "",
"description": "Type-safe error-handling library for TypeScript",
"repository": {
"type": "git",
"url": "git+https://github.com/bkiac/ruts.git"
},
"author": "bkiac <[email protected]>",
"license": "MIT",
"main": "./lib/index.cjs",
"module": "./lib/index.js",
"exports": {
".": "./lib/index.js",
"./internal": "./lib/internal.js"
".": {
"types": "./lib/index.d.ts",
"require": "./lib/index.cjs",
"import": "./lib/index.js"
},
"./internal": {
"types": "./lib/internal.d.ts",
"require": "./lib/internal.cjs",
"import": "./lib/internal.js"
},
"./package.json": "./package.json"
},
"types": "./lib/index.d.ts",
"files": [
Expand All @@ -25,18 +35,20 @@
"result-type"
],
"scripts": {
"build": "rm -rf lib && tsc --p tsconfig.build.json && prettier --write ./lib --ignore-path ''",
"build": "tsup --config ./cfg/tsup.config.ts && pnpm build:ts",
"build:ts": "tsc --p ./cfg/tsconfig.types.json",
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepublishOnly": "pnpm run build",
"test": "vitest",
"types": "tsc"
"test": "vitest --config ./cfg/vitest.config.ts",
"ts:check": "tsc"
},
"devDependencies": {
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.0.2",
"prettier-plugin-pkg": "^0.18.0",
"tsup": "^7.2.0",
"tsx": "^3.14.0",
"typescript": "^5.0.4",
"vitest": "^0.34.6"
Expand Down
Loading

0 comments on commit d3e7694

Please sign in to comment.