|
| 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