Skip to content

Commit a1853ab

Browse files
committed
ci: add react18 compatibility lane and pack smoke tests
1 parent c32507f commit a1853ab

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,58 @@ jobs:
4646
env:
4747
CI: true
4848

49+
verify-react18:
50+
name: Verify React 18 (Node 22.x)
51+
runs-on: ubuntu-latest
52+
permissions:
53+
contents: read
54+
env:
55+
CI: true
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
- name: Setup pnpm
60+
uses: pnpm/action-setup@v4
61+
- name: Use Node.js 22.x
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: 22.x
65+
cache: pnpm
66+
cache-dependency-path: pnpm-lock.yaml
67+
- name: Install dependencies
68+
run: pnpm install --frozen-lockfile
69+
- name: Install React 18 lane dependencies
70+
run: pnpm add -D react@^18.0.0 react-dom@^18.0.0 @types/react@^18.0.0 @types/react-dom@^18.0.0
71+
- name: Verify
72+
run: |
73+
pnpm typecheck
74+
pnpm test
75+
pnpm test:it
76+
pnpm build
77+
78+
pack-smoke:
79+
name: Pack Smoke (Node 22.x)
80+
runs-on: ubuntu-latest
81+
permissions:
82+
contents: read
83+
env:
84+
CI: true
85+
86+
steps:
87+
- uses: actions/checkout@v4
88+
- name: Setup pnpm
89+
uses: pnpm/action-setup@v4
90+
- name: Use Node.js 22.x
91+
uses: actions/setup-node@v4
92+
with:
93+
node-version: 22.x
94+
cache: pnpm
95+
cache-dependency-path: pnpm-lock.yaml
96+
- name: Install dependencies
97+
run: pnpm install --frozen-lockfile
98+
- name: Run pack smoke tests
99+
run: bash ./scripts/pack-smoke.sh
100+
49101
e2e:
50102
name: E2E (Chromium)
51103
runs-on: ubuntu-latest

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"typecheck": "tsc -p tsconfig.build.json --noEmit",
5151
"test": "vitest run",
5252
"test:it": "vitest run --config vitest.it.config.ts",
53+
"test:pack-smoke": "bash ./scripts/pack-smoke.sh",
5354
"test:watch": "vitest",
5455
"test:e2e": "playwright test",
5556
"clean": "rm -rf dist coverage"

scripts/pack-smoke.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
TMP_DIR="$(mktemp -d)"
6+
PACK_DIR="$TMP_DIR/pack"
7+
SMOKE_DIR="$TMP_DIR/smoke"
8+
9+
cleanup() {
10+
rm -rf "$TMP_DIR"
11+
}
12+
trap cleanup EXIT
13+
14+
mkdir -p "$PACK_DIR" "$SMOKE_DIR"
15+
16+
cd "$ROOT_DIR"
17+
TARBALL_PATH="$(pnpm pack --pack-destination "$PACK_DIR" | tail -n 1)"
18+
19+
cat > "$SMOKE_DIR/package.json" <<'JSON'
20+
{
21+
"name": "fict-react-pack-smoke",
22+
"private": true,
23+
"type": "module"
24+
}
25+
JSON
26+
27+
pnpm --dir "$SMOKE_DIR" add "$TARBALL_PATH"
28+
pnpm --dir "$SMOKE_DIR" add @fictjs/runtime@^0.10.0 react@^19.0.0 react-dom@^19.0.0 vite@^7.0.0 @vitejs/plugin-react@^5.0.0
29+
pnpm --dir "$SMOKE_DIR" add -D typescript@^5.9.0 @types/node@^25.0.0
30+
31+
pnpm --dir "$SMOKE_DIR" exec node --input-type=module -e "
32+
const core = await import('@fictjs/react')
33+
const loader = await import('@fictjs/react/loader')
34+
const preset = await import('@fictjs/react/preset')
35+
36+
if (typeof core.reactify !== 'function') throw new Error('Missing ESM export reactify')
37+
if (typeof core.reactify$ !== 'function') throw new Error('Missing ESM export reactify$')
38+
if (typeof loader.installReactIslands !== 'function') throw new Error('Missing ESM export installReactIslands')
39+
if (typeof preset.fictReactPreset !== 'function') throw new Error('Missing ESM export fictReactPreset')
40+
"
41+
42+
pnpm --dir "$SMOKE_DIR" exec node -e "
43+
const core = require('@fictjs/react')
44+
const loader = require('@fictjs/react/loader')
45+
const preset = require('@fictjs/react/preset')
46+
47+
if (typeof core.reactify !== 'function') throw new Error('Missing CJS export reactify')
48+
if (typeof core.reactify$ !== 'function') throw new Error('Missing CJS export reactify$')
49+
if (typeof loader.installReactIslands !== 'function') throw new Error('Missing CJS export installReactIslands')
50+
if (typeof preset.fictReactPreset !== 'function') throw new Error('Missing CJS export fictReactPreset')
51+
"
52+
53+
cat > "$SMOKE_DIR/tsconfig.json" <<'JSON'
54+
{
55+
"compilerOptions": {
56+
"target": "ES2022",
57+
"module": "NodeNext",
58+
"moduleResolution": "NodeNext",
59+
"strict": true,
60+
"skipLibCheck": true,
61+
"noEmit": true
62+
},
63+
"include": ["smoke.ts"]
64+
}
65+
JSON
66+
67+
cat > "$SMOKE_DIR/smoke.ts" <<'TS'
68+
import { type MountReactRootOptions, type MountedReactRoot, reactify, reactify$ } from '@fictjs/react'
69+
import { installReactIslands } from '@fictjs/react/loader'
70+
import { fictReactPreset, type FictReactPresetOptions } from '@fictjs/react/preset'
71+
72+
type _Compat1 = MountReactRootOptions
73+
74+
type _Compat2 = MountedReactRoot
75+
76+
const _opts: FictReactPresetOptions = {}
77+
78+
if (typeof reactify !== 'function') {
79+
throw new Error('reactify type/runtime mismatch')
80+
}
81+
82+
if (typeof reactify$ !== 'function') {
83+
throw new Error('reactify$ type/runtime mismatch')
84+
}
85+
86+
if (typeof installReactIslands !== 'function') {
87+
throw new Error('installReactIslands type/runtime mismatch')
88+
}
89+
90+
if (typeof fictReactPreset !== 'function') {
91+
throw new Error('fictReactPreset type/runtime mismatch')
92+
}
93+
94+
void _opts
95+
TS
96+
97+
pnpm --dir "$SMOKE_DIR" exec tsc -p "$SMOKE_DIR/tsconfig.json"

0 commit comments

Comments
 (0)