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

chore: make dependencies external #977

Merged

Conversation

GerkinDev
Copy link
Contributor

@GerkinDev GerkinDev commented Mar 9, 2023

Closes #974

Dependencies used at runtime were moved in peer dependencies. Package.json is read in order to extract dependencies to make external.

Size changes results

File Before After
react-tooltip.cjs.js 51K 31K
react-tooltip.cjs.js.map 95K 53K
react-tooltip.cjs.min.js 26K 13K
react-tooltip.cjs.min.js.map 96K 55K
react-tooltip.css 1.7K 1.7K
react-tooltip.css.map 1.7K 1.7K
react-tooltip.esm.js 50K 28K
react-tooltip.esm.js.map 95K 52K
react-tooltip.esm.min.js 26K 11K
react-tooltip.esm.min.js.map 96K 54K
react-tooltip.iife.js 54K 32K
react-tooltip.iife.js.map 95K 52K
react-tooltip.iife.min.js 26K 13K
react-tooltip.iife.min.js.map 95K 54K
react-tooltip.min.js 26K 11K
react-tooltip.min.js.map 96K 54K

This PR is marked as draft because I could not get example-v5 to work from main in order to tweak it and compare its dist bundle in situ. I could use some help just to make sure example-v5 works correctly before the PR

@danielbarion
Copy link
Member

@GerkinDev thanks for this PR, we really appreciate it!

About the folder example-v5: @gabrieljablonski I believe we should delete this branch, as the example folder is related to V4 and for V5 we are using the docs folder to test the tooltip, please let me know your thoughts.

@danielbarion
Copy link
Member

danielbarion commented Mar 9, 2023

@GerkinDev just released a beta version for this PR:

npm install [email protected]

or

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@GerkinDev
Copy link
Contributor Author

GerkinDev commented Mar 9, 2023

Docs site work without problem after the modification locally. Since I don't have an easy boilerplate to compare bundle size with @floating-ui already used or not, I did not get you final bundle results in demo app. Yet, I'm confident it should not cause additional problems.


I also noticed that packages target multiple versions of react:

"react": "16.14.0",
"react-dom": "16.14.0",

"react": "^18.2.0",
"react-dom": "^18.2.0",

While it does not prevent the docs site from building in the current state, it might cause troubles


Final note: lockfiles weren't changed, since I don't use neither yarn nor npm. I suggest you do a commit atop this PR with lockfile changes before merging it, if/when you plan to do it

@gabrieljablonski
Copy link
Member

About the folder example-v5: @gabrieljablonski I believe we should delete this branch, as the example folder is related to V4 and for V5 we are using the docs folder to test the tooltip, please let me know your thoughts.

Yeah, just delete it.

@gabrieljablonski
Copy link
Member

I also noticed that packages target multiple versions of react

I don't think this should ever be a problem. The component targets react 16 so that older projects can still use the tooltip.

@gabrieljablonski
Copy link
Member

gabrieljablonski commented Mar 9, 2023

As a side note, why is bundlephobia not detecting @floating-ui/dom and classnames as dependencies?

https://bundlephobia.com/package/[email protected]
image

Here's kind of how it should look like, comparing with another package https://bundlephobia.com/package/@floating-ui/[email protected]

image

@danielbarion
Copy link
Member

danielbarion commented Mar 9, 2023

As a side note, why is bundlephobia not detecting @floating-ui/dom and classnames as dependencies?

Yeah, good question 🤔

@GerkinDev
Copy link
Contributor Author

GerkinDev commented Mar 9, 2023

Ah I think I understand why: it seems to get the size of dependencies, not peerDependencies. It's also possible it relies on lockfiles.

@GerkinDev
Copy link
Contributor Author

GerkinDev commented Mar 9, 2023

Might you try a new alpha release from latest commit ? I did not find anything in the bundlephobia repo to explain how composition is calculated. If this does not work, then I would suppose it relies on lockfiles

@GerkinDev GerkinDev force-pushed the chore/dependencies-external branch from 9dc0f79 to 7cb9d92 Compare March 9, 2023 15:13
@GerkinDev GerkinDev marked this pull request as ready for review March 9, 2023 15:13
@GerkinDev GerkinDev force-pushed the chore/dependencies-external branch from 7cb9d92 to 930221d Compare March 9, 2023 15:30
@GerkinDev GerkinDev force-pushed the chore/dependencies-external branch from 930221d to ab449c4 Compare March 9, 2023 15:32
@gabrieljablonski
Copy link
Member

Might you try a new alpha release from latest commit ? I did not find anything in the bundlephobia repo to explain how composition is calculated. If this does not work, then I would suppose it relies on lockfiles

[email protected] has been published, looks ok now

https://bundlephobia.com/package/[email protected]
image

@danielbarion
Copy link
Member

Looks good to me but are you sure this will close the open issue @GerkinDev?

I'm just double-checking :)

@GerkinDev
Copy link
Contributor Author

GerkinDev commented Mar 9, 2023

I'm confident about it but as mentioned above I did not have the time to fact-check in situ by inspecting manually a prod build of a demo app comparing following situations:

  • before external without external use of @floating-ui
  • before external with external use of @floating-ui
  • after external without external use of @floating-ui
  • after external with external use of @floating-ui
    Outputs from docs are way too heavy to demangle it & check. I will take the time for it a bit later, if you want hard facts as guarantee

@GerkinDev
Copy link
Contributor Author

GerkinDev commented Mar 9, 2023

Sample app attached along with individual reports: test-app.zip

No floating UI use With floating UI use
No external image 185840B image 234641B
With external image 184636B image 217092B

Looks good to me ;)

@danielbarion
Copy link
Member

danielbarion commented Mar 9, 2023

Thanks for confirming @GerkinDev!

@danielbarion
Copy link
Member

just waiting for @gabrieljablonski

Copy link
Member

@gabrieljablonski gabrieljablonski left a comment

Choose a reason for hiding this comment

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

👍

@danielbarion
Copy link
Member

@GerkinDev I'll merge this one now but I want to run some tests locally related to building that is breaking next.js apps with SWC active, so we will do a new release as soon as possible.

Thank you so much for this contribution!

@danielbarion danielbarion merged commit cf6d5bd into ReactTooltip:master Mar 10, 2023
@GerkinDev GerkinDev deleted the chore/dependencies-external branch March 10, 2023 16:10
danielbarion added a commit that referenced this pull request Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT REQ] Keep dependencies external in build results
3 participants