Skip to content

Commit

Permalink
feat: zero dependencies (#9)
Browse files Browse the repository at this point in the history
* feat: zero dependencies and only esm support

* fix: lint

* fix: esm export

* fix: lint

* fix: export

* fix: cjs
  • Loading branch information
productdevbook authored Nov 27, 2023
1 parent 99cdec1 commit 3d60839
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
],
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
Expand All @@ -47,15 +46,13 @@
"test:watch": "vitest --watch",
"coverage": "vitest run --coverage"
},
"dependencies": {
"ofetch": "^1.3.3"
},
"devDependencies": {
"@antfu/eslint-config": "2.1.0",
"@vitest/coverage-v8": "^0.34.6",
"bumpp": "^9.2.0",
"eslint": "^8.54.0",
"lint-staged": "^15.1.0",
"ofetch": "^1.3.3",
"simple-git-hooks": "^2.9.0",
"tsup": "^8.0.1",
"typescript": "^5.3.2",
Expand Down
12 changes: 7 additions & 5 deletions pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ofetch } from 'ofetch'
import { $fetch } from 'ofetch'
import type { ClientConfig, ClientResponse, NoResponse, UserRes } from './types'
import { monitorManager, projectsManager, servicesManager, settingsManager } from './managers'
import { Routes } from './utils/Routes'
Expand All @@ -8,7 +8,7 @@ let token = ''
function client(config: ClientConfig): ClientResponse {
token = config.token

const customClient = ofetch.create({
const customClient = $fetch.create({
headers: {
'Content-Type': 'application/json',
'Authorization': config.token,
Expand Down
12 changes: 4 additions & 8 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import type { Options } from 'tsup'

import pkg from './package.json'

const external = [
...Object.keys(pkg.dependencies || {}),
]

export default <Options>{
entryPoints: ['src/index.ts'],
outDir: 'dist',
format: ['esm', 'cjs'],
sourcemap: true,
sourcemap: false,
clean: true,
dts: true,
minify: true,
external,
noExternal: [
'ofetch',
],
}

0 comments on commit 3d60839

Please sign in to comment.