Skip to content

Commit

Permalink
chore(): migrate to my own shared lib, esm fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chyzwar committed Oct 23, 2023
1 parent bd3bf76 commit 65eec38
Show file tree
Hide file tree
Showing 48 changed files with 1,342 additions and 1,252 deletions.
2 changes: 0 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ module.exports = {
project: [
"./tsconfig.eslint.json",
"./packages/*/tsconfig.json",
"./clients/*/tsconfig.json",
"./services/*/tsconfig.json",
],
tsconfigRootDir: __dirname,
},
Expand Down
1 change: 1 addition & 0 deletions jest.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export default {
transform: {},
projects: [
"<rootDir>/packages/*/jest.config.js",
"<rootDir>/packages/*/jest.config.ts",
],
};
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "module",
"workspaces": {
"packages": [
"packages/**"
"packages/**",
"packages/*/examples"
]
},
"lint-staged": {
Expand All @@ -26,13 +27,13 @@
"prepare": "husky install"
},
"devDependencies": {
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"eslint": "^8.29.0",
"husky": "^8.0.2",
"jest": "^29.3.1",
"lint-staged": "^13.1.0",
"typescript": "^4.9.4"
"@commitlint/cli": "^18.0.0",
"@commitlint/config-conventional": "^18.0.0",
"eslint": "^8.52.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"lint-staged": "^15.0.2",
"typescript": "^5.2.2"
},
"packageManager": "yarn@3.6.3"
}
15 changes: 15 additions & 0 deletions packages/event-emitter/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "http://json.schemastore.org/swcrc",
"isModule": true,
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript",
"dynamicImport": false
}
},
"module": {
"type": "es6",
"resolveFully": true
}
}
9 changes: 0 additions & 9 deletions packages/event-emitter/jest.config.js

This file was deleted.

17 changes: 17 additions & 0 deletions packages/event-emitter/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type {Config} from "jest";

const config: Config = {
displayName: "@hyper/event-emitter",
testEnvironment: "jsdom",
rootDir: "src",
testMatch: ["**/__tests__/**/*.ts?(x)", "**/?(*.)+(spec|test).ts?(x)"],
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.(t|j)sx?$": "@swc/jest",
},
};

export default config;
2 changes: 2 additions & 0 deletions packages/event-emitter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"devDependencies": {
"@chyzwar/eslint-config": "^0.2.0",
"@chyzwar/tsconfig": "^0.2.0",
"@swc/core": "^1.3.94",
"@swc/jest": "^0.2.29",
"eslint": "^8.29.0",
"jest": "^29.3.1",
"typescript": "^4.9.4"
Expand Down
15 changes: 15 additions & 0 deletions packages/generic-types/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "http://json.schemastore.org/swcrc",
"isModule": true,
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript",
"dynamicImport": false
}
},
"module": {
"type": "es6",
"resolveFully": true
}
}
10 changes: 5 additions & 5 deletions packages/generic-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"author": "chyzwar",
"license": "UNLICENSED",
"devDependencies": {
"@chyzwar/eslint-config": "^0.2.2",
"@chyzwar/tsconfig": "^0.2.2",
"eslint": "^8.29.0",
"jest": "^29.3.1",
"typescript": "^4.9.4"
"@chyzwar/eslint-config": "^0.2.14",
"@chyzwar/tsconfig": "^0.2.14",
"eslint": "^8.52.0",
"jest": "^29.7.0",
"typescript": "^5.2.2"
},
"files": [
"src/",
Expand Down
4 changes: 3 additions & 1 deletion packages/generic-types/src/Abstract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

type Abstract<T> = Function & { prototype: T };
type Abstract<T> = Function & {
prototype: T;
};

export default Abstract;
15 changes: 15 additions & 0 deletions packages/http-client/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "http://json.schemastore.org/swcrc",
"isModule": true,
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript",
"dynamicImport": false
}
},
"module": {
"type": "es6",
"resolveFully": true
}
}
10 changes: 5 additions & 5 deletions packages/http-client/examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"@hyper/http-client": "0.x.x"
},
"devDependencies": {
"@chyzwar/eslint-config": "^0.2.2",
"@chyzwar/tsconfig": "^0.2.2",
"@types/node": "^18.11.12",
"eslint": "^8.29.0",
"@chyzwar/eslint-config": "^0.2.14",
"@chyzwar/tsconfig": "^0.2.14",
"@types/node": "^18.18.6",
"eslint": "^8.52.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^5.2.2"
}
}
3 changes: 3 additions & 0 deletions packages/http-client/examples/browser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "@chyzwar/tsconfig/lib.json",
"compilerOptions": {
"rootDir": "src"
},
"include": [
"src/**/*.ts",
"src/**/*.json"
Expand Down
10 changes: 5 additions & 5 deletions packages/http-client/examples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"@hyper/utils": "0.x.x"
},
"devDependencies": {
"@chyzwar/eslint-config": "^0.2.2",
"@chyzwar/tsconfig": "^0.2.2",
"@types/node": "^18.11.12",
"eslint": "^8.29.0",
"@chyzwar/eslint-config": "^0.2.14",
"@chyzwar/tsconfig": "^0.2.14",
"@types/node": "^18.18.6",
"eslint": "^8.52.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^5.2.2"
}
}
2 changes: 1 addition & 1 deletion packages/http-client/examples/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

{
"extends": "@hyper/tsc-config",
"extends": "@chyzwar/tsconfig/api.json",
"include": [
"src/**/*.ts",
"src/**/*.json"
Expand Down
15 changes: 11 additions & 4 deletions packages/http-client/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import type {Config} from 'jest';
import type {Config} from "jest";

const config: Config = {
displayName: "@hyper/http-client",
testEnvironment: "jsdom",
transform: {},
roots: ["<rootDir>/src/"],
rootDir: "src",
testMatch: ["**/__tests__/**/*.ts?(x)", "**/?(*.)+(spec|test).ts?(x)"],
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.(t|j)sx?$": "@swc/jest",
},
};

export default config
export default config;
14 changes: 7 additions & 7 deletions packages/http-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"@hyper/utils": "0.x.x"
},
"devDependencies": {
"@chyzwar/eslint-config": "^0.2.0",
"@chyzwar/tsconfig": "^0.2.0",
"@types/node": "^18.11.12",
"eslint": "^8.29.0",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"typescript": "^4.9.4"
"@chyzwar/eslint-config": "^0.2.14",
"@chyzwar/tsconfig": "^0.2.14",
"@types/node": "^18.18.6",
"eslint": "^8.52.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"typescript": "^5.2.2"
},
"files": [
"src/",
Expand Down
4 changes: 4 additions & 0 deletions packages/http-client/src/__tests__/BrowserClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import BrowserClient from "../BrowserClient.js";
describe("BrowserClient", () => {
const mockFetchPromise = Promise.resolve({
ok: true,
headers: {
get: jest.fn(),
},
blob: async() => Promise.resolve({google: "ok"}),
json: async() => Promise.resolve({google: "ok"}),
} as unknown as Response);

Expand Down
1 change: 1 addition & 0 deletions packages/http-client/src/types/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type RequestOptions from "./RequestOptions.js";
import type ResponseType from "./ResponseType.js";

abstract class BaseClient {

/**
* Perform HTTP POST request
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/http-server/benchmarks/body-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"version": "1.0.0",
"description": "compare performance express.js vs hyper vs ",
"scripts": {
"start:express": "node ./express.js",
"start:hyper": "node ./hyper.js",
"start:express": "node ./express.cjs",
"start:hyper": "node ./hyper.mjs",
"start:fastify": "node ./fastify.js"
},
"author": "chyzwar",
"license": "MIT",
"dependencies": {
"@hyper/http-server": "0.x.x",
"body-parser": "^1.20.1",
"body-parser": "^1.20.2",
"express": "^4.18.2",
"fastify": "^4.10.2"
"fastify": "^4.24.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const router = express.Router();
const app = express();

router.get("/home", (req, res) => {
res.json({express:"Hello World"});
res.json({express: "Hello World"});
});

app.use(router);
Expand Down
7 changes: 1 addition & 6 deletions packages/http-server/benchmarks/hello-world/fastify.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-floating-promises */

import fastify from "fastify";
Expand All @@ -9,11 +8,7 @@ server.get("/home", (request, reply) => {
reply.send({hello: "world"});
});

server.listen(3200,
/**
* @param {Error} [err]
* @param {String} [address]
*/
server.listen({port: 3200},
(err, address) => {
if (err) {
console.error(`Server error on ${err.message}`);
Expand Down
6 changes: 3 additions & 3 deletions packages/http-server/benchmarks/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"hyper": "node ./hyper.js",
"express": "node ./express.js",
"express": "node ./express.cjs",
"fastify": "node ./fastify.js",
"benchmark": "node ./benchmark.js"
},
Expand All @@ -14,8 +14,8 @@
"dependencies": {
"@hyper/http-server": "0.x.x",
"@hyper/logger": "0.x.x",
"autocannon": "^7.10.0",
"autocannon": "^7.12.0",
"express": "^4.18.2",
"fastify": "^4.10.2"
"fastify": "^4.24.3"
}
}
4 changes: 2 additions & 2 deletions packages/http-server/examples/body-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"dependencies": {
"@hyper/http-server": "0.x.x",
"@hyper/logger": "0.x.x",
"@types/node": "^18.11.12"
"@types/node": "^18.18.6"
},
"devDependencies": {
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^5.2.2"
}
}
8 changes: 4 additions & 4 deletions packages/http-server/examples/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"dependencies": {
"@hyper/http-server": "0.x.x",
"@hyper/logger": "0.x.x",
"@types/node": "^18.11.12"
"@types/node": "^18.18.6"
},
"devDependencies": {
"@chyzwar/eslint-config": "^0.2.2",
"eslint": "^8.29.0",
"@chyzwar/eslint-config": "^0.2.14",
"eslint": "^8.52.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^5.2.2"
}
}
4 changes: 2 additions & 2 deletions packages/http-server/examples/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"license": "MIT",
"dependencies": {
"@hyper/http-server": "0.x.x",
"@types/node": "^18.11.12"
"@types/node": "^18.18.6"
},
"devDependencies": {
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^5.2.2"
}
}
Loading

0 comments on commit 65eec38

Please sign in to comment.