Skip to content

🐛 fix: mark package side-effect free so unused exports tree-shake - #7

Merged
Innei merged 1 commit into
mainfrom
fix/side-effects-free
Nov 3, 2026
Merged

Innei merged 1 commit into
mainfrom
fix/side-effects-free

Conversation

@Innei

@Innei Innei commented Nov 3, 2026

Copy link
Copy Markdown
Member

Problem

@lobehub/streamdown has no sideEffects field. Its modules also have top-level statements a bundler can't prove pure: memo(...) calls with no /* @__PURE__ */ annotation and X.displayName = ... assignments. So importing a single helper keeps every streamdown component, and through them react-markdown, unified, the remark/rehype stack and katex.

@lobehub/ui re-exports rehypeStreamAnimated from its root barrel. As a result, import { Button } from '@lobehub/ui' alone pulled about 450KB of raw markdown/katex code into a consumer bundle.

Fix

  • Add "sideEffects": false to package.json. Nothing in src/ runs at import time: no CSS imports, no global writes, no registration. StreamdownStyles renders a <style> element inside a component.
  • Add a test that asserts the field so it can't silently regress.

Verification

Consumer bench: Vite 7 / rollup, React 19, @lobehub/ui 6.15.0, entry import { Button, MotionProvider } from '@lobehub/ui'. Minified / gzip JS:

JS
before 744.32 KB / 233.52 KB
with "sideEffects": false 280.90 KB / 92.44 KB
deep import @lobehub/ui/es/Button/index (reference) 281 KB / 92.4 KB

vitest run: 10 files / 200 tests pass. tsc --noEmit is clean.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T17:35:38.623641Z
We couldn’t complete this review. Comment @codex review to try again.
d2d2905 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying streamdown with  Cloudflare Pages  Cloudflare Pages

Latest commit: d2d2905
Status:🚫  Build failed.

View logs

@Innei
Innei merged commit 299e394 into main Nov 3, 2026
1 of 2 checks passed
@Innei
Innei deleted the fix/side-effects-free branch November 3, 2026 17:38
lobe-tsukumo Bot pushed a commit that referenced this pull request Nov 3, 2026
## [1.4.5](v1.4.4...v1.4.5) (2026-11-03)

### 🐛 Bug Fixes

* Mark package side-effect free so unused exports tree-shake, closes [#7](#7) ([299e394](299e394))
@lobe-tsukumo

lobe-tsukumo Bot commented Nov 3, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.4.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lobe-tsukumo lobe-tsukumo Bot added the released label Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant