Skip to content

Leave the reveal out of bundles that import only the hooks (0.2.2) - #8

Merged
crmapache merged 1 commit into
mainfrom
pure-component-annotations
Oct 16, 2026
Merged

crmapache merged 1 commit into
mainfrom
pure-component-annotations

Conversation

@crmapache

Copy link
Copy Markdown
Owner

An app that imports only useSmoothText from smooth-stream-text/react, or only useSmoothStream from smooth-stream-text/vue, bundled the reveal too. The components that live in the same entry are created by forwardRef, createContext and defineComponent calls at the top of the module, and a bundler keeps calls like that unless they are marked pure. In React, SmoothText also built a set of option names when the module loaded, which kept the default reveal settings alive.

The calls are now marked /* @__PURE__ */, and SmoothText looks option names up on the defaults instead. Measured the way the benchmark does it (esbuild, minified, gzip), on the same toolchain before and after:

Import Before After
React useSmoothText 8.2 kB 4.7 kB
React Reveal, RevealProvider 8.1 kB 4.6 kB
React SmoothText 8.0 kB 7.8 kB
React, everything 8.67 kB 8.68 kB
Vue useSmoothStream 8.2 kB 4.6 kB
Vue, everything 8.4 kB 8.4 kB

The 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.mjs bundles 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 as npm 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.

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.
@vercel

vercel Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
smooth-stream-text Ready Ready Preview Oct 16, 2026 7:36pm UTC

@crmapache
crmapache merged commit e3c37b8 into main Oct 16, 2026
15 checks passed
@crmapache
crmapache deleted the pure-component-annotations branch October 16, 2026 20:04

This branch was successfully deployed

1 active deployment
Preview — d8a9e6d3 Deployed Oct 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant