Skip to content

Commit 9324766

Browse files
committed
feat!: Dropped compatibility for Node 20.x.
1 parent 0d5f975 commit 9324766

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
fail-fast: false
88
matrix:
99
os: [ubuntu-latest, windows-latest]
10-
node-version: [20.18.0, 22, 23]
10+
node-version: [22, 23]
1111
runs-on: ${{ matrix.os }}
1212
steps:
1313
- name: Checkout
@@ -28,7 +28,6 @@ jobs:
2828
- name: Install dependencies
2929
run: pnpm install --shamefully-hoist
3030
- name: Run Tests
31-
if: matrix.os != 'windows-latest' && matrix.node-version != '20.18.0'
3231
run: pnpm run ci
3332
- name: Upload coverage to Codecov
3433
uses: codecov/codecov-action@v3

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ If you need to configure the script at runtime, use environment variables and op
2929

3030
### TypeScript
3131

32-
cronometro can run on TypeScript files. Type deletion happens on the fly with no additional configuration required.
33-
34-
Use the `TS_NODE_PROJECT` environment variable to provide a TypeScript configuration.
32+
cronometro can run on TypeScript files via [Node.js native types stripping](https://nodejs.org/dist/latest-v22.x/docs/api/typescript.html#type-stripping).
3533

3634
### API use
3735

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"postpublish": "git push origin && git push origin -f --tags"
4040
},
4141
"dependencies": {
42-
"@swc-node/register": "^1.10.9",
4342
"acquerello": "^3.0.1",
4443
"hdr-histogram-js": "^3.0.0",
4544
"table": "^6.9.0"
@@ -56,6 +55,6 @@
5655
"typescript": "^5.7.2"
5756
},
5857
"engines": {
59-
"node": ">= 20.18.0"
58+
"node": ">= 22.6.0"
6059
}
6160
}

src/index.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,20 @@ function run(context: Context): void {
5050
errorThreshold: context.errorThreshold
5151
}
5252

53-
const worker = new Worker(runnerPath, { workerData })
53+
/* c8 ignore next 5 */
54+
let nodeOptions = process.env.NODE_OPTIONS ?? ''
55+
const nodeMajor = Number(process.versions.node.split('.')[0])
56+
if (nodeMajor < 23) {
57+
nodeOptions += ' --experimental-strip-types '
58+
}
59+
60+
const worker = new Worker(runnerPath, {
61+
workerData,
62+
env: {
63+
...process.env,
64+
NODE_OPTIONS: nodeOptions
65+
}
66+
})
5467

5568
if (context.onTestStart) {
5669
context.onTestStart(name, workerData, worker)

src/runner.ts

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ if (isMainThread) {
77
throw new Error('Do not run this file as main script.')
88
}
99

10-
if (workerData.path.endsWith('.ts')) {
11-
await import('@swc-node/register/esm-register')
12-
}
13-
1410
// Require the script to set tests
1511
try {
1612
const module = await import(workerData.path)

test/config/c8-local.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"reporter": ["text", "html"],
3-
"all": true,
4-
"include": ["src/**/*.ts"],
5-
"exclude": ["**/node_modules/**", "test/**/*.ts"]
2+
"reporter": ["text", "html"]
63
}

0 commit comments

Comments
 (0)