Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize code + dependencies to prepare for React 19 #99

Merged
merged 7 commits into from
Apr 29, 2024

Conversation

karmeleon
Copy link
Contributor

@karmeleon karmeleon commented Apr 25, 2024

This started as "remove defaultProps because React 19 drops support for them" but sort of expanded a bit when a bunch of stuff failed to install.

Runtime changes:

  • defaultProps replaced with ES6 default parameters.
  • @babel/preset-react now uses the jsx transform instead of React.createElement, since it's also unsupported in React 19.
  • @babel/preset-env updated to target > 0.25%, not dead, so features like arrow functions are required at runtime (unless you transpile the module).
  • Switched minifier to terser because uglify is no longer supported.

The above changes reduce the tarball size from ~16k to ~12k, and likely include runtime benefits from the new transform, lack of defaultProps (which sound like they carry a penalty), and reduction in polyfills.

Dev environment changes:

  • Tons of devDeps upgraded. Webpack, ESLint, Jest, Babel, Flow, Prettier, and React all needed bumping either to support the new features, modern Node, or other upgraded packages.
  • Since ESLint and Prettier were upgraded, there were some style changes.
  • Snapshots updated, as default destructures don't show up in snapshots like defaultProps did.
  • Python venv upgraded to 3.10.
  • Node version bumped to v16.
  • pre-commit config updated to actually work.
  • Travis-CI removed, replaced with Github Actions
    • n.b. the publish step is necessarily untested, but was copied from another Yelp repo so assuming that still works and the npm secret is org-wide, this should work too.

Verification

Tests all pass, and swapping this version in for the current latest version in my local dev environment both renders correctly and quiets all the deprecation warnings under React 18.3.0.

I plan to release this as a major version.

@karmeleon karmeleon merged commit c4e7199 into master Apr 29, 2024
1 check passed
@karmeleon karmeleon deleted the shawn_no_more_defaultprops branch April 29, 2024 23:35
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.

2 participants