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

Support React 19 #8

Merged
merged 17 commits into from
Dec 31, 2024
Merged

Support React 19 #8

merged 17 commits into from
Dec 31, 2024

Conversation

RobinTail
Copy link
Contributor

@RobinTail RobinTail commented Dec 30, 2024

Fixes #7

Including general maintenance: upgrading all dependencies and adjusting some configs.
ATTW is also up to date and some adjustments made to the generated DTS files (now needs two of them, for each of the javascript bundles). This job was given to the Vite DTS plugin instead of tsc.
Configuration of extenals is updated to avoid bundling clipboard dependency which is supposed to be installed on consumer side. That reduced the bundle size significantly.

Tested manually:

  • React 18 ✅
  • React 19 ✅

@RobinTail
Copy link
Contributor Author

Tested manually that the bundle works both with React 18 and 19.

src/App.tsx Outdated Show resolved Hide resolved
@@ -2,7 +2,7 @@

## react-clipboard-button

- [x] very light (~33KB not minified)
- [x] very light (~1.2KB not minified)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by extenalizing the clipboard dependency in vite config.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @RobinTail , thanks for the contribution!
Regarding this change, if I'm not mistaken, it means users will have to npm install clipboard in addition to installing our library ? Any reason why you are removing the dependency from the bundle ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it will happen automatically, because clipboard is listed as the production dependency, @guipas
Therefore it does not have to be bundled, because it's installed along with your packaage.

Copy link
Contributor Author

@RobinTail RobinTail Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"dependencies": {
"clipboard": "^2.0.8"

Listing in dependencies makes clipboard installed into node_modules on the consumer side along with this package. It's a subdependency accessible during the build on the consumer side. So you don't need to bundle clipboard into react-clipboard-button, @guipas

Copy link
Contributor Author

@RobinTail RobinTail Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

users will have to npm install clipboard in addition

That would only be necessary if listing a dependency within peerDependencies, where react is listed in, for example, @guipas
Peer dependencies are not installed automatically.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok yeah that makes sense! thank you, I'll merge this PR

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll publish on npm later this week

@RobinTail RobinTail marked this pull request as ready for review December 30, 2024 13:35
@RobinTail
Copy link
Contributor Author

@guipas , please review

@guipas guipas merged commit 89e3e9f into guipas:main Dec 31, 2024
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.

React 19 incompatible
2 participants