-
Notifications
You must be signed in to change notification settings - Fork 76
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
Switch to Preconstruct for library building #520
Switch to Preconstruct for library building #520
Conversation
@Andarist is attempting to deploy a commit to the Cloudinary DevX Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@Andarist one clarifying thing, so this doesn't set up subpath imports, correct? this just bundles a bit differently so that we can successfully apply the directive in the relevant components? what impact does this have on tree-shaking, does this improve? maintain the same? i thought we had treeshaking covered but a comment in another Issue made it sound like that wasn't the case i'm also curious about if it impacts the size, but ill test this out locally too |
is there a reason the components get their own files but the helpers dont? jsut curious about how that works in practice. what is determined to split into its own chunk? |
Yes, it doesn't introduce any extra entrypoints but they can easily be done by:
With Preconstruct
When it comes to file-splitting - yes, this is the main difference here. It ensures that all files with the
It's roughly the same.
I'll prepare this week a breakdown of how tree-shaking performs with this setup and recheck if anything can be improved. I feel like people usually misread some stats and get imprecise takeaways based on them. Tree-shaking is actually quite simple algorithm and the rules are pretty simple. At the same time, there are various optimizations at play and people might often refer to all of them combined as tree-shaking so it's often hard to answer questions like this without analyzing how it actually plays out for any given library/situation. Once I'm done with the writeup, I can try to answer followup questions to clear up how it works in practice and what kind of rule of thumbs you could stick to to ensure that it doesn't regress in the future etc.
It should roughly be the same for consumers. The install size also shouldn't be affected in a meaningful way. This doesn't use any extra builds beyond just ESM and CJS and you already had those 2 here.
No.
Components relying on hooks need to be isolated so they stay in files with
Those are not that important in the today's landscape though. The first concern is addressed by Flat bundling is Rollup's default so we just kinda stick to it when possible. It's also nice that the module resolver doesn't always have to resolve a bunch of relative imports here but that's a microoptimization at best in the grand scheme of things :p |
# [7.0.0-beta.1](v6.13.0...v7.0.0-beta.1) (2024-09-27) ### Features * Switch to Preconstruct for library building ([#520](#520)) ([a35a928](a35a928)) ### BREAKING CHANGES * New build tool, no longer requires `use client` directive, marking as breaking for safety
🎉 This PR is included in version 7.0.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This PR switches away from tsup to preconstruct - a lesser-known but more capable tool.
The benefits are:
'use client'
directive support. With this you just can just add the directive to any of your files and Preconstruct takes care of isolating that in its own chunkpackage.json#exports
flexibility:next-cloudinary/something
)react-server
condition)Issue Ticket Number
Related to #435
Type of change
Checklist