Skip to content

feat: add React 19 support and modernize build tooling - #2

Open
samiashi wants to merge 6 commits into
lyst:masterfrom
samiashi:chore/upgrade-dependencies
Open

feat: add React 19 support and modernize build tooling#2
samiashi wants to merge 6 commits into
lyst:masterfrom
samiashi:chore/upgrade-dependencies

Conversation

@samiashi

Copy link
Copy Markdown

Summary

Adds React 19 support to @lyst/hypernova-react and modernizes the toolchain. The package was last released in July 2023, pinned to React 18 with a Babel stack that no longer works against the maintained Babel 8. This brings everything up to date while keeping backward compatibility with existing React 18 consumers.

What changed

React 19 support

  • renderReact now hydrates with hydrateRoot unconditionally (the React 18/19 react-dom/client API), removing the dead createRoot fallback. renderToString remains the server path.
  • peerDependencies widened to react/react-dom ^18.2.0 || ^19.0.0 — React 18 apps keep working, React 19 apps are newly supported.
  • Test suite now exercises the client hydration path against React 19 (new jsdom suite), and the server markup test.

Toolchain modernization

  • Replaced the unmaintained babel-preset-airbnb with maintained @babel/preset-env + @babel/preset-react on Babel 8, upgrading @babel/core/@babel/cli to 8.x.
  • Forced "modules": "commonjs" in Babel config — Babel 8 defaults to leaving ESM in lib/, which would have silently broken CommonJS consumers of main: lib/index.js.
  • Test/dev stack updated: jest 29 → 30, prettier 2 → 3, TypeScript 5 → 7, plus @types/react and jest-environment-jsdom.
  • CI modernized: actions/checkout@v4 / setup-node@v4, Node 20/22/24 matrix, explicit build + typecheck + test run.

Bump the package to 4.0.0 (major) and modernize the full build stack:

- Widen peerDependencies to React ^18.2.0 || ^19.0.0 so existing React 18
  consumers keep working while React 19 is now supported; move devDependencies
  to current versions (react/react-dom ^19.2.8, @babel/* 8, jest 30,
  jest-environment-jsdom 30, prettier 3, TypeScript 7).
- Replace the unmaintained babel-preset-airbnb with the maintained
  @babel/preset-env and @babel/preset-react on Babel 8.
- Force modules: "commonjs" in .babelrc: Babel 8's CLI self-reports ESM
  support, so the default 'auto' mode would leave ESM in lib/ and break
  CommonJS consumers of main: lib/index.js.
- Add engines: node >=18 and typecheck/check scripts that typecheck the
  shipped TypeScript typings with tsc.
- Add @types/react and jest-environment-jsdom devDependencies for the
  typecheck and client-hydration test suite.
react-dom/client guarantees hydrateRoot in React 18+, so the guarded
createRoot().render() fallback was dead code. Render each server-serialized
instance with hydrateRoot directly; renderToString stays the server path, so
behavior is otherwise unchanged.
Serialize a server-rendered Hypernova payload (via renderToString +
serialize), render it into a jsdom document, then call renderReact's client
branch and assert the component resumes on the server node with the
server-provided props under React 19.

Uses jest-environment-jsdom since the hypernova() client path runs only when
a DOM is present.
- Replace the commented-out single server signature with real overloads for
  both the server and client branches of renderReact, plus the exported
  ServerRenderedComponent (props -> HTML string) mapping.
- Add tsconfig.json (strict, React JSX, NodeNext module resolution) so the
  package's own declarations are verified by tsc --noEmit on TypeScript 7 via
  the npm run typecheck script.
- Bump checkout and setup-node to v4 in both CI and publish workflows.
- Test across the current active Node LTS lines (20.x, 22.x, 24.x) instead
  of the old 16.x-20.x matrix, and publish on Node 24.
- CI now runs an explicit build plus tsc typecheck before the jest suite so
  compile output, type checking, and tests are all verified.
Update the README tagline to reflect the widened peer dependency range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant