chore: mark package as sideEffects: false to enable tree-shaking#160
Open
mvanhorn wants to merge 1 commit intochenglou:mainfrom
Open
chore: mark package as sideEffects: false to enable tree-shaking#160mvanhorn wants to merge 1 commit intochenglou:mainfrom
mvanhorn wants to merge 1 commit intochenglou:mainfrom
Conversation
Himaan1998Y
pushed a commit
to Himaan1998Y/pretext
that referenced
this pull request
May 4, 2026
npm install from github: requires dist/ present — the prepack script uses rm -rf (POSIX-only) and bun, so GitHub Actions/npm won't rebuild it reliably. Pre-committing the dist built from our patched source (PRs chenglou#160, chenglou#161, chenglou#132) ensures consumers get the correct artifact.
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.
Summary
Add
"sideEffects": falseto package.json so downstream bundlers can tree-shake unused exports of@chenglou/pretext.Why this matters
Per #158, the
darkroomengineering/fitboxmaintainer's bundle audit shows ~129 KB of pretext modules ship to every consumer regardless of which exports they actually import:analysis.jsline-break.jsgenerated/bidi-data.jslayout.jsmeasurement.jsbidi.jsA consumer importing only
prepareWithSegments,measureNaturalWidth,measureLineStats,layoutWithLinesships the full set today.A scan of the published modules confirms there are no top-level side effects:
let sharedWordSegmenter = nulland the regex/Set initializers are pure expressions, evaluated lazily on first call. Marking the package side-effect-free is safe and lets bundlers drop unused exports based on what consumers import.Realistic impact per #158: 20-40% bundle reduction for consumers using a subset of the API.
Changes
One line in
package.json:Testing
bun run build:package— clean buildbun run check—tsc && oxlint --type-aware srcreports 0 warnings, 0 errorsbun test— 103 pass, 0 fail (417 expect calls)No source code touched, no behavior change.
Fixes #158