-
-
Notifications
You must be signed in to change notification settings - Fork 958
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
Fix tree shaking #661
Fix tree shaking #661
Conversation
|
@jeetiss is attempting to deploy a commit to the wagmi Team on Vercel. A member of the Team first needs to authorize it. |
New and updated dependency changes detected. Learn more about Socket for GitHub ↗︎
Footnotes |
Hey there. Good find!
Is that a bug in webpack? Doesn't hurt to add that property here but feels like webpack should traverse to & inherit that from the package.json of the package.
Instead of introducing another build step & babel for that, let's just add that annotation to the offending root level function calls in |
I don't know exactly, but it seems as not.
I wouldn't say I like this either, but this solution is bulletproof and typescript doesn't provide any way to achieve the same result. Current code contains 110 pure annotations: Any usage without annotations would include the But ofc, I can set comments manually if you don't like the costs of |
Oh okay, so the annotation is needed for more than just the |
yes, it is used for all define functions: Pure annotations affect |
Just gave this a test run, and it seems to strip out all the sourcemap comments. Can we stop it from doing that? |
@jeetiss Could you split this into two PRs? One for just adding the We are currently researching our options for that and don't have a super clear picture yet. A lot of the discussions both in the typescript repository are super recent and inconclusive: We also found some interesting related discussions and recent activity for rollup, esbuild, etc. that are relevant:
I dislike the proposed babel solution because it feels somewhat icky to post-process the build output with an additional step effectively fiddling with the dist artifacts after build. I'm worried about how that might potentially affect source maps too. My personal preference for the annotations would be:
This is my personal preference with admitedly only rather superficial understanding of the status quo of tooling support & best practices for these annotations in general. |
@fubhy yes ofc, I will split this PR I found that I can run
It looks like a good compromise for me before What do you think? |
Yeah that sounds good. Adding them to the source code would also give us an idea how many of those are necessary and how much maintenance burden that would add going forward. @jxom Also identified a potential problem with how EDIT: That base error class issue is solved with this: #684 |
This PR contains a command to add close in favor of #687 |
hello, folks
I fixed two tree-shaking issues with this PR
package.json
indist/esm
overrides default one so webpack doesn't seesideEffects: false
option and disables optimizations. I added this field.sideEffects: false
is specified, so I added/*#__PURE__*/
annotation with babel pluginsize before:
size after:
PR-Codex overview
This PR adds pure annotation to the codebase and updates some dependencies.
Detailed summary
babel-plugin-annotate-pure-calls
plugin.@babel/cli
and@babel/core
dependencies.@babel/plugin-syntax-typescript
dependency.size-limit
configuration to include new size limits for different parts of the codebase.sideEffects
to thepackage.json
file to optimize tree-shaking.