Skip to content

Commit

Permalink
Convert package to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad committed Jan 19, 2024
1 parent 29de91a commit b8a8097
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:vitest/recommended",
"plugin:import-esm/recommended",
"prettier"
],
"rules": {
Expand Down Expand Up @@ -56,6 +57,7 @@
"newlines-between": "always"
}
],
"import/no-unresolved": ["off"],
"object-shorthand": ["error", "always"],
"max-lines": ["error", { "max": 600 }],
"max-params": ["error", { "max": 4 }],
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Frontend HTTP client

Opinionated HTTP client for the frontend.

Note that it is a ESM-only package.

## Basic usage

```ts
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { sendPost, sendGet, sendPut, sendDelete, sendPatch } from './src/client'
export { sendPost, sendGet, sendPut, sendDelete, sendPatch } from './src/client.js'
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@lokalise/frontend-http-client",
"version": "1.0.1",
"description": "Opinionated HTTP client for the frontend",
"files": [
"dist/**",
"LICENSE",
Expand Down Expand Up @@ -45,13 +46,24 @@
"jest-fail-on-console": "^3.1.2",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-vitest": "^0.3.17",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-vitest": "^0.3.20",
"eslint-plugin-import-esm": "^1.2.1",
"mockttp": "^3.10.1",
"prettier": "^3.2.4",
"rimraf": "^5.0.5",
"typescript": "~5.3.3",
"vitest": "^1.2.1"
},
"keywords": [
"frontend",
"web",
"browser",
"http",
"client",
"zod",
"validation",
"typesafe"
],
"prettier": "@lokalise/prettier-config"
}
2 changes: 1 addition & 1 deletion src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getLocal } from 'mockttp'
import wretch from 'wretch'
import { z } from 'zod'

import { sendDelete, sendGet, sendPatch, sendPost, sendPut } from './client'
import { sendDelete, sendGet, sendPatch, sendPost, sendPut } from './client.js'

describe('frontend-http-client', () => {
const mockServer = getLocal()
Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { stringify } from 'fast-querystring'
import { type ZodSchema, type ZodError } from 'zod'

import { type Either, failure, success, isFailure } from './either'
import { type Either, failure, success, isFailure } from './either.js'
import type {
CommonRequestParams,
NoQueryParams,
QueryParams,
ResourceChangeParams,
WretchInstance,
} from './types'
} from './types.js'

function parseRequestBody<RequestBody>({
body,
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "ESNext",
"module": "node16",
"target": "ES2022",
"lib": ["ES2022", "dom"],
"sourceMap": false,
"declaration": true,
"declarationMap": false,
"types": ["node", "vitest/globals"],
"strict": true,
"moduleResolution": "bundler",
"moduleResolution": "node16",
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
Expand Down

0 comments on commit b8a8097

Please sign in to comment.