Repository navigation
Leave the reveal out of bundles that import only the hooks (0.2.2) - #8
Merged
Merged
Conversation
The React and Vue entries create their components with forwardRef, createContext and defineComponent at the top of the module. Bundlers keep such calls unless they are marked pure, so an app importing only useSmoothText or useSmoothStream bundled the whole reveal as well: 8.2 kB gzipped instead of 4.7 kB (React) and 4.6 kB (Vue). The calls are now marked /* @__PURE__ */, and SmoothText looks its option names up instead of building a set at module load. scripts/check-tree-shaking.mjs bundles the hook-only imports with esbuild and fails if the reveal is in them; CI and the release run it. Version 0.2.2.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An app that imports only
useSmoothTextfromsmooth-stream-text/react, or onlyuseSmoothStreamfromsmooth-stream-text/vue, bundled the reveal too. The components that live in the same entry are created byforwardRef,createContextanddefineComponentcalls at the top of the module, and a bundler keeps calls like that unless they are marked pure. In React,SmoothTextalso built a set of option names when the module loaded, which kept the default reveal settings alive.The calls are now marked
/* @__PURE__ */, andSmoothTextlooks option names up on the defaults instead. Measured the way the benchmark does it (esbuild, minified, gzip), on the same toolchain before and after:useSmoothTextReveal,RevealProviderSmoothTextuseSmoothStreamThe core alone is 4.2 kB. Vite's Rolldown build drops the reveal from the hook-only bundle as well. Runtime behaviour does not change; the existing SmoothText test now also checks that settings never land on the element as attributes.
To keep it that way,
scripts/check-tree-shaking.mjsbundles the hook-only imports of every entry and fails if the reveal is in them, with the reveal imports as controls so the check cannot go blind. CI and the release workflow run it asnpm run check:bundle.The version is 0.2.2, with a changelog entry. Merging does not publish; the benchmark results are rerun after the release, as for 0.2.1.