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

Very large code size on web #2683

Open
edkimmel opened this issue Nov 24, 2023 · 2 comments
Open

Very large code size on web #2683

edkimmel opened this issue Nov 24, 2023 · 2 comments
Assignees
Labels
Close when stale The issue will be closed automatically if it remains inactive Missing repro Platform: Web

Comments

@edkimmel
Copy link

Description

Screenshot 2023-11-24 at 5 19 19 PM

react-native-gesture-handler is a very heavy dependency on web.

At a glance, both the web and native gesture / handler implementations are being included. I believe that by wrapping the underlying gestures in the GestureObject export, tree-shaking has been effectively disabled as well.

Steps to reproduce

Include react-native-gesture-handler on web.

Snack or a link to a repository

n/a

Gesture Handler version

2.9.0

React Native version

0.71

Platforms

Web

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@latekvo latekvo self-assigned this Nov 25, 2024
@latekvo
Copy link
Contributor

latekvo commented Jan 9, 2025

Hi, it looks like the package size isn't much larger on web than it is on other platforms.
On android it's 306kB, and on web it's 492kB, but that's including the web-specific handlers implementation, which isn't present on other platforms.

I looked into your concern about loading native implementations while on web, but that doesn't seem to be the case.
The only files I found to be loaded were the non-platform-specific, and the web-specific files.

Regarding your concerns about tree shaking, it's unavailable in Metro, and as far as i understand, the tree-shaking that is provided by alternatives like Re.pack don't really work on the code of imported libraries, but instead optimize your imports of sideEffect-free libraries.

Exception to that is when a library provides multiple nested packages, but Gesture Handler doesn't really do that for most of it's features besides a few exceptions, which would probably save you around 20kB if tree-shaken.

@latekvo latekvo added the Close when stale The issue will be closed automatically if it remains inactive label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Close when stale The issue will be closed automatically if it remains inactive Missing repro Platform: Web
Projects
None yet
Development

No branches or pull requests

3 participants