Skip to content

Commit 715d5fe

Browse files
committed
Merge phase 1: modern toolchain (still JS)
Replaces webpack + Grunt + Babel with tsdown (dual ESM+CJS+UMD+.d.ts, generated exports map), Jest with Vitest, ESLint 4 with ESLint 9 flat config + Prettier scaffold, sets Node 18+ / drops IE11, and stands up GitHub Actions CI (ci.yml) with a release.yml scaffold, replacing .travis.yml. No library behavior changed. Full suite green against wp-env: 805 passed, 16 skipped, 0 failed — identical to the Phase 0 baseline. See handoff.md for the tricky decisions and workarounds this phase required.
2 parents 4113576 + d8f2c37 commit 715d5fe

45 files changed

Lines changed: 5262 additions & 405 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

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

.eslintrc.js

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

.github/workflows/ci.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
jobs:
9+
# tsdown/rolldown require Node >=22.18 to run; vitest requires >=20. The
10+
# published library itself only requires Node >=18 (see `engines` in
11+
# package.json) — that promise is checked separately by `dist-smoke` below,
12+
# against the pre-built output, without needing the build tooling to run.
13+
test:
14+
name: Lint, typecheck, build & unit test (Node ${{ matrix.node-version }})
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
node-version: [ 22, 24, latest ]
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: npm
25+
- run: npm ci
26+
- run: npm run lint
27+
- run: npm run typecheck
28+
- run: npm run build
29+
- run: npm run test:unit
30+
- if: matrix.node-version == 'latest'
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: dist
34+
path: dist
35+
retention-days: 1
36+
37+
dist-smoke:
38+
name: Published dist works on Node ${{ matrix.node-version }}
39+
runs-on: ubuntu-latest
40+
needs: test
41+
strategy:
42+
matrix:
43+
node-version: [ 18, 20 ]
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: actions/setup-node@v4
47+
with:
48+
node-version: ${{ matrix.node-version }}
49+
cache: npm
50+
- run: npm ci --omit=dev
51+
- uses: actions/download-artifact@v4
52+
with:
53+
name: dist
54+
path: dist
55+
- run: |
56+
node -e "
57+
const WPAPI = require('./dist/index.cjs');
58+
const wp = new WPAPI({ endpoint: 'http://localhost/wp-json' });
59+
if (typeof wp.posts !== 'function') throw new Error('CJS entry did not bootstrap');
60+
"
61+
node --input-type=module -e "
62+
import WPAPI from './dist/index.mjs';
63+
const wp = new WPAPI({ endpoint: 'http://localhost/wp-json' });
64+
if (typeof wp.posts !== 'function') throw new Error('ESM entry did not bootstrap');
65+
"
66+
67+
integration:
68+
name: Integration tests (wp-env)
69+
runs-on: ubuntu-latest
70+
timeout-minutes: 15
71+
steps:
72+
- uses: actions/checkout@v4
73+
- uses: actions/setup-node@v4
74+
with:
75+
node-version: 22
76+
cache: npm
77+
- run: npm ci
78+
- run: npm run env:start
79+
- run: npm run env:seed
80+
- run: npm run test:integration
81+
# `npm run env:logs` defaults to `--watch`, which never exits; pass
82+
# `--no-watch` directly so this step prints once and completes.
83+
- if: always()
84+
run: npx @wordpress/env logs development --no-watch
85+
- if: always()
86+
run: npm run env:stop

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
# Scaffolded in Phase 1, replacing the local `release-npm` script; not yet
4+
# exercised until publishing resumes (requires an `NPM_TOKEN` secret).
5+
on:
6+
release:
7+
types: [ published ]
8+
9+
jobs:
10+
publish:
11+
name: Build, test & publish to npm
12+
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
# tsdown/rolldown require Node >=22.18 to run the build itself.
20+
node-version: 22
21+
cache: npm
22+
registry-url: https://registry.npmjs.org
23+
- run: npm ci
24+
- run: npm run lint
25+
- run: npm run typecheck
26+
- run: npm run build
27+
- run: npm run test:unit
28+
- run: npm publish --provenance --access public
29+
env:
30+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,5 @@ documentation/index.html
4545
*.sublime-*
4646
.ruby-version
4747

48-
# Built files (for use in browser)
49-
browser/
50-
51-
# Consuming applications should maintain their own lockfile.
52-
package-lock.json
48+
# Built files (tsdown output: ESM/CJS/UMD + .d.ts)
49+
dist/

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"useTabs": true,
3+
"singleQuote": true,
4+
"semi": true,
5+
"trailingComma": "all",
6+
"printWidth": 90
7+
}

.travis.yml

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

Gruntfile.js

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

build/.eslintrc.js

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

build/browser-shims/form-data.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict';
2+
3+
// Browser build stand-in for `form-data`: use the native global instead.
4+
module.exports = FormData;

0 commit comments

Comments
 (0)