Skip to content

Commit f0dd94f

Browse files
authored
feat!: update build to esm (#58)
BREAKING CHANGE: update dependencies
1 parent 92de542 commit f0dd94f

18 files changed

Lines changed: 5492 additions & 4901 deletions

.eslintrc.js

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

.github/workflows/release.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ jobs:
77
release:
88
name: Release
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
issues: write
13+
pull-requests: write
14+
id-token: write
1015
steps:
1116
- name: Checkout
12-
uses: actions/checkout@v2
17+
uses: actions/checkout@v6.0.1
1318
with:
1419
fetch-depth: 0
1520
- name: Setup Node.js
16-
uses: actions/setup-node@v1
21+
uses: actions/setup-node@v6.1.0
1722
with:
18-
node-version: 14.17.0
23+
node-version: v24.12.0
1924
- name: Install dependencies
2025
run: yarn install --frozen-lockfile
2126
- name: Run tests
@@ -25,5 +30,4 @@ jobs:
2530
- name: Release
2631
env:
2732
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2933
run: yarn release

.github/workflows/test_branch.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v6.0.1
1313
with:
1414
fetch-depth: 0
1515
- name: Setup Node.js
16-
uses: actions/setup-node@v1
16+
uses: actions/setup-node@v6.1.0
1717
with:
18-
node-version: 14.17.0
18+
node-version: v24.12.0
1919
- name: Install dependencies
2020
run: yarn install --frozen-lockfile
2121
- name: Lint code

eslint.config.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import jest from 'eslint-plugin-jest';
2+
import importPlugin from 'eslint-plugin-import';
3+
import tsPlugin from '@typescript-eslint/eslint-plugin';
4+
5+
export default [
6+
{
7+
ignores: ['src/examples/**', 'src/bench/**'],
8+
},
9+
...tsPlugin.configs['flat/recommended'],
10+
{
11+
plugins: {
12+
import: importPlugin,
13+
},
14+
settings: importPlugin.configs.typescript.settings,
15+
rules: {
16+
...importPlugin.configs.errors.rules,
17+
...importPlugin.configs.warnings.rules,
18+
...importPlugin.configs.typescript.rules,
19+
},
20+
},
21+
{
22+
plugins: {
23+
jest,
24+
},
25+
rules: {
26+
'@typescript-eslint/no-var-requires': 0,
27+
'@typescript-eslint/no-explicit-any': 0,
28+
'@typescript-eslint/no-empty-function': 0,
29+
'@typescript-eslint/explicit-function-return-type': 0,
30+
'@typescript-eslint/explicit-module-boundary-types': 0,
31+
'@typescript-eslint/prefer-namespace-keyword': 0,
32+
'@typescript-eslint/no-non-null-assertion': 0,
33+
'@typescript-eslint/no-use-before-define': 0,
34+
'max-classes-per-file': ['error', 1],
35+
'import/prefer-default-export': 0,
36+
'import/no-dynamic-require': 0,
37+
'import/named': 2,
38+
'import/namespace': 2,
39+
'import/default': 2,
40+
'import/export': 2,
41+
'import/no-unresolved': 0,
42+
'import/order': [
43+
'error',
44+
{
45+
'newlines-between': 'always',
46+
groups: ['external', 'internal', 'index', 'sibling', 'parent', 'builtin'],
47+
},
48+
],
49+
'import/no-extraneous-dependencies': [
50+
'error',
51+
{
52+
devDependencies: true,
53+
optionalDependencies: false,
54+
peerDependencies: false,
55+
},
56+
],
57+
},
58+
},
59+
];

jest.config.js renamed to jest.config.cjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
module.exports = {
2-
preset: 'ts-jest',
32
testEnvironment: 'node',
3+
extensionsToTreatAsEsm: ['.ts'],
4+
transform: {
5+
'^.+\\.ts$': ['ts-jest', { useESM: true, tsconfig: 'tsconfig.json' }],
6+
},
7+
moduleNameMapper: {
8+
'^callsites$': '<rootDir>/src/__tests__/__mocks__/callsites.cjs',
9+
},
410
collectCoverageFrom: ['<rootDir>/src/**/*.ts'],
511
coveragePathIgnorePatterns: ['<rootDir>/src/examples'],
612
testMatch: ['<rootDir>/src/**/**.test.ts'],

package.json

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@
33
"version": "0.6.0",
44
"description": "Lightweight and fast Node.js web server",
55
"main": "lib/index.js",
6+
"types": "lib/index.d.ts",
7+
"exports": {
8+
".": {
9+
"types": "./lib/index.d.ts",
10+
"import": "./lib/index.js"
11+
}
12+
},
613
"directories": {
714
"lib": "lib",
815
"test": "__tests__"
916
},
1017
"files": [
1118
"lib"
1219
],
20+
"type": "module",
21+
"engines": {
22+
"node": ">=22"
23+
},
1324
"scripts": {
1425
"build": "rm -rf ./lib && tsc -p tsconfig.build.json",
1526
"build:dev": "rm -rf ./dev-lib && tsc -p tsconfig.dev.json",
@@ -33,46 +44,46 @@
3344
},
3445
"license": "MIT",
3546
"dependencies": {
36-
"ajv": "^8.11.0",
37-
"callsites": "^3.1.0",
38-
"cookie": "^0.5.0",
39-
"cookie-signature": "^1.2.0",
40-
"find-my-way": "^5.6.0",
41-
"hyperid": "^2.3.1",
47+
"ajv": "^8.17.1",
48+
"callsites": "^4.2.0",
49+
"cookie": "^1.1.1",
50+
"cookie-signature": "^1.2.2",
51+
"find-my-way": "^9.3.0",
52+
"hyperid": "^3.3.0",
4253
"lodash": "^4.17.21",
43-
"pino": "^7.11.0",
44-
"pino-pretty": "^7.6.1",
45-
"ts-morph": "^14.0.0",
46-
"ws": "^8.6.0"
54+
"pino": "^10.1.0",
55+
"pino-pretty": "^13.1.3",
56+
"ts-morph": "^27.0.2",
57+
"ws": "^8.18.3"
4758
},
4859
"devDependencies": {
4960
"@semantic-release/git": "^10.0.1",
50-
"@semantic-release/github": "^8.0.2",
51-
"@ts-morph/bootstrap": "^0.12.2",
52-
"@types/cookie": "^0.4.1",
53-
"@types/cookie-signature": "^1.0.3",
54-
"@types/jest": "^27.0.3",
55-
"@types/node": "^14.17.0",
56-
"@types/pino": "^7.0.5",
57-
"@types/ws": "^8.2.1",
58-
"@typescript-eslint/eslint-plugin": "^5.5.0",
59-
"@typescript-eslint/parser": "^5.5.0",
60-
"axios": "^0.21.1",
61-
"eslint": "^8.3.0",
62-
"eslint-plugin-import": "^2.25.3",
63-
"eslint-plugin-jest": "^25.3.0",
64-
"express": "^4.17.1",
65-
"fastify": "^3.24.1",
66-
"jest": "^27.4.3",
67-
"prettier": "^2.5.1",
68-
"semantic-release": "^18.0.1",
69-
"supertest": "^6.1.3",
70-
"ts-jest": "^27.0.7",
71-
"ts-node-dev": "^1.1.6",
72-
"typescript": "^4.6.4"
61+
"@semantic-release/github": "^12.0.2",
62+
"@ts-morph/bootstrap": "^0.28.1",
63+
"@types/cookie": "^0.6.0",
64+
"@types/cookie-signature": "^1.1.2",
65+
"@types/jest": "^30.0.0",
66+
"@types/node": "^25.0.3",
67+
"@types/pino": "^7.0.4",
68+
"@types/ws": "^8.18.1",
69+
"@typescript-eslint/eslint-plugin": "^8.50.1",
70+
"@typescript-eslint/parser": "^8.50.1",
71+
"axios": "^1.13.2",
72+
"eslint": "^9.39.2",
73+
"eslint-plugin-import": "^2.32.0",
74+
"eslint-plugin-jest": "^29.11.0",
75+
"express": "^5.2.1",
76+
"fastify": "^5.6.2",
77+
"jest": "^30.2.0",
78+
"prettier": "^3.7.4",
79+
"semantic-release": "^25.0.2",
80+
"supertest": "^7.1.4",
81+
"ts-jest": "^29.4.6",
82+
"ts-node-dev": "^2.0.0",
83+
"typescript": "^5.9.3"
7384
},
7485
"optionalDependencies": {
75-
"bufferutil": "^4.0.3",
76-
"utf-8-validate": "^5.0.5"
86+
"bufferutil": "^4.1.0",
87+
"utf-8-validate": "^6.0.6"
7788
}
7889
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function mockCallsite() {
2+
return {
3+
getFileName() {
4+
return 'mock';
5+
},
6+
getLineNumber() {
7+
return 1;
8+
},
9+
getColumnNumber() {
10+
return 1;
11+
},
12+
getFunctionName() {
13+
return 'mock';
14+
},
15+
};
16+
}
17+
18+
module.exports = function callsites() {
19+
return [mockCallsite(), mockCallsite(), mockCallsite()];
20+
};

src/__tests__/server.integration.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ test('Enables cookies attachment in the settings', async () => {
6969
const { headers } = await axios.get(`http://localhost:${app.getServerPort()}/test`);
7070
await app.stop();
7171

72-
expect(headers['set-cookie'][0]).toContain(
73-
'important=cookie; Domain=example.com; Path=/; Expires=',
74-
);
72+
const setCookie = headers['set-cookie'];
73+
const firstCookie = Array.isArray(setCookie) ? setCookie[0] : setCookie;
74+
75+
expect(firstCookie).toContain('important=cookie; Domain=example.com; Path=/; Expires=');
7576
});
7677

7778
test('Sets x-processing-time to milliseconds', async () => {

src/examples/bare-http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ app.route.declare({
7676
handler: function multipleDeclarationRoute(flow) {
7777
flow.params.param;
7878
},
79-
methods: ['get', 'post'],
79+
methods: ['post'],
8080
});
8181

8282
const _wait = () => new Promise((resolve) => setTimeout(resolve, 5000));

src/logger/serializers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import callsites from 'callsites';
33
import { context } from '../context';
44

55
import util from 'util';
6-
76
import type { IncomingMessage, ServerResponse } from 'http';
87

98
export function parseError(e: any, meta: any) {

0 commit comments

Comments
 (0)