Skip to content

Commit d13b510

Browse files
authored
BREAKING: Make module ESM only (#1746)
1 parent 738b083 commit d13b510

13 files changed

Lines changed: 301 additions & 807 deletions

File tree

.github/workflows/nodejs-test.yml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ on:
99
env:
1010
CI: true
1111
FORCE_COLOR: 2
12-
NODE_COV: lts/* # The Node.js version to run coveralls on
1312

1413
permissions:
15-
contents: read # to fetch code (actions/checkout)
14+
contents: read
1615

1716
jobs:
1817
lint:
@@ -27,20 +26,16 @@ jobs:
2726
- run: npm run lint
2827

2928
test:
30-
permissions:
31-
contents: read # to fetch code (actions/checkout)
32-
checks: write # to create new checks (coverallsapp/github-action)
33-
3429
name: Node ${{ matrix.node }}
3530
runs-on: ubuntu-latest
3631

3732
strategy:
3833
fail-fast: false
3934
matrix:
4035
node:
41-
- 18
4236
- 20
4337
- 22
38+
- 24
4439
- lts/*
4540

4641
steps:
@@ -52,18 +47,4 @@ jobs:
5247
cache: npm
5348
- run: npm ci
5449
- run: npm run build --if-present
55-
56-
- name: Run Jest
57-
run: npm run test:vi
58-
if: matrix.node != env.NODE_COV
59-
60-
- name: Run Jest with coverage
61-
run: npm run test:vi -- --coverage
62-
if: matrix.node == env.NODE_COV
63-
64-
- name: Run Coveralls
65-
uses: coverallsapp/github-action@v2.3.7
66-
if: matrix.node == env.NODE_COV
67-
continue-on-error: true
68-
with:
69-
github-token: "${{ secrets.GITHUB_TOKEN }}"
50+
- run: npm run test:vi

.github/workflows/publish.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- uses: actions/checkout@v6
17+
18+
- uses: actions/setup-node@v6
19+
with:
20+
node-version: lts/*
21+
registry-url: https://registry.npmjs.org
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Create jsr.json based on package.json
27+
run: |
28+
node --input-type=module -e '
29+
import { readFileSync, writeFileSync } from "fs";
30+
const p = JSON.parse(readFileSync("./package.json", "utf8"));
31+
const jsrJson = {
32+
name: `@cheerio/${p.name}`,
33+
version: p.version,
34+
exports: { ".": "./src/index.ts" },
35+
imports: {
36+
"boolbase": `jsr:@cheerio/boolbase@${p.dependencies.boolbase}`,
37+
"css-what": `jsr:@cheerio/css-what@${p.dependencies["css-what"]}`,
38+
"domhandler": `jsr:@cheerio/domhandler@${p.dependencies.domhandler}`,
39+
"domutils": `jsr:@cheerio/domutils@${p.dependencies.domutils}`,
40+
"nth-check": `jsr:@cheerio/nth-check@${p.dependencies["nth-check"]}`,
41+
},
42+
};
43+
writeFileSync("./jsr.json", JSON.stringify(jsrJson, null, 2));
44+
'
45+
46+
- name: Publish package to JSR
47+
run: npx jsr publish
48+
49+
- name: Publish package to npm
50+
run: npm publish --provenance --access public

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
.vscode/
22
node_modules/
33
coverage/
4-
lib/
54
dist/
6-
.tshy/
7-
.tshy-build/
5+
jsr.json

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.4.5/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.4.7/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",

0 commit comments

Comments
 (0)