Skip to content

Commit 29e87ad

Browse files
authored
feat(export): Setup ESM first (#46)
* feat(export): Setup ESM first * Switch to Vitest
1 parent 5514d36 commit 29e87ad

20 files changed

+2163
-1023
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- run: yarn add --dev rxjs@~${{ matrix.rxjs }}
2929
- run: yarn compile
3030
- run: yarn lint
31-
- run: yarn test --forbid-only
31+
- run: yarn test
3232

3333
check:
3434
runs-on: ubuntu-latest

.mocharc.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

eslint.config.mjs renamed to eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ export default eslintTs.config(
112112
"@stylistic/switch-colon-spacing": "error",
113113
"@typescript-eslint/ban-types": "error",
114114
"@typescript-eslint/consistent-type-assertions": "error",
115-
"@typescript-eslint/consistent-type-exports": "off",
116-
"@typescript-eslint/consistent-type-imports": ["off", { fixStyle: "inline-type-imports" }],
115+
"@typescript-eslint/consistent-type-exports": "error",
116+
"@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "inline-type-imports" }],
117117
"@typescript-eslint/dot-notation": "error",
118118
"@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }],
119119
"@typescript-eslint/explicit-member-accessibility": "error",

package.json

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,42 @@
1717
"rxjs",
1818
"rxjs-observable"
1919
],
20-
"main": "./dist/index.js",
21-
"types": "./dist/index.d.ts",
20+
"type": "module",
21+
"source": "./src/main.ts",
22+
"main": "./dist/main.cjs",
23+
"module": "./dist/main.js",
24+
"unpkg": "./dist/main.umd.cjs",
25+
"types": "./dist/main.d.ts",
26+
"sideEffects": false,
27+
"exports": {
28+
".": {
29+
"import": "./dist/main.js",
30+
"require": "./dist/main.cjs",
31+
"types": "./dist/main.d.ts",
32+
"default": "./dist/main.js"
33+
},
34+
"./package.json": "./package.json"
35+
},
2236
"files": [
23-
"dist/",
24-
"src/"
37+
"./dist",
38+
"./src",
39+
"./package.json"
2540
],
2641
"engines": {
2742
"node": ">=18"
2843
},
2944
"scripts": {
30-
"build": "tsc -p tsconfig.prod.json",
31-
"check": "yarn compile && yarn lint && yarn test --forbid-only",
45+
"build": "vite build",
46+
"check": "yarn compile && yarn lint && yarn test --run",
3247
"compile": "tsc",
3348
"lint": "eslint .",
3449
"release": "semantic-release",
35-
"test": "NODE_ENV=test mocha"
50+
"test": "NODE_ENV=test vitest"
3651
},
3752
"packageManager": "yarn@4.3.1",
53+
"dependencies": {
54+
"pino": "^9.2.0"
55+
},
3856
"devDependencies": {
3957
"@assertive-ts/core": "^2.1.0",
4058
"@assertive-ts/sinon": "^1.0.0",
@@ -44,7 +62,6 @@
4462
"@stylistic/eslint-plugin": "^2.2.2",
4563
"@types/eslint__eslintrc": "^2.1.1",
4664
"@types/eslint__js": "^8.42.3",
47-
"@types/mocha": "^10.0.7",
4865
"@types/node": "^20.14.8",
4966
"@types/sinon": "^17.0.3",
5067
"axios": "^1.7.2",
@@ -57,7 +74,6 @@
5774
"eslint-plugin-jsdoc": "^48.2.15",
5875
"eslint-plugin-sonarjs": "^1.0.3",
5976
"form-data": "^4.0.0",
60-
"mocha": "^10.4.0",
6177
"msw": "^2.3.1",
6278
"rxjs": "^7.8.1",
6379
"semantic-release": "^24.0.0",
@@ -66,7 +82,10 @@
6682
"ts-node": "^10.9.2",
6783
"tslib": "^2.6.3",
6884
"typescript": "^5.5.2",
69-
"typescript-eslint": "^7.13.1"
85+
"typescript-eslint": "^7.13.1",
86+
"vite": "^5.3.1",
87+
"vite-plugin-dts": "^3.9.1",
88+
"vitest": "^1.6.0"
7089
},
7190
"peerDependencies": {
7291
"axios": ">=1.0.0",
@@ -83,8 +102,5 @@
83102
"publishConfig": {
84103
"access": "public",
85104
"provenance": true
86-
},
87-
"dependencies": {
88-
"pino": "^9.2.0"
89105
}
90106
}

src/lib/RxjsAxios.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import axios, {
2-
AxiosError,
3-
AxiosInstance,
4-
AxiosInterceptorManager,
5-
AxiosRequestConfig,
6-
AxiosRequestHeaders,
7-
AxiosResponseHeaders,
8-
Cancel,
9-
CreateAxiosDefaults,
10-
FormSerializerOptions,
11-
GenericFormData,
12-
GenericHTMLFormElement,
13-
AxiosResponse as OriginalAxiosResponse,
2+
type AxiosError,
3+
type AxiosInstance,
4+
type AxiosInterceptorManager,
5+
type AxiosRequestConfig,
6+
type AxiosRequestHeaders,
7+
type AxiosResponseHeaders,
8+
type Cancel,
9+
type CreateAxiosDefaults,
10+
type FormSerializerOptions,
11+
type GenericFormData,
12+
type GenericHTMLFormElement,
13+
type AxiosResponse as OriginalAxiosResponse,
1414
} from "axios";
1515
import pino from "pino";
16-
import { Observable } from "rxjs";
1716

1817
import { observify } from "./observify";
1918

19+
import type { Observable } from "rxjs";
20+
2021
export type AxiosResponse<T, D = unknown> = OriginalAxiosResponse<T, D>;
2122

2223
export type AxiosObservable<T> = Observable<AxiosResponse<T>>;
File renamed without changes.

test/helpers/mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HttpResponse, PathParams, http } from "msw";
1+
import { HttpResponse, type PathParams, http } from "msw";
22

33
export interface User {
44
id?: number;

test/hooks.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/index.test.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)