Strip did-you-mean suggestions from production client bundles - #221
Merged
Conversation
The Levenshtein edit-distance implementation in name-suggestions.ts shipped in every production client bundle via unguarded error paths in resolveApp and buildHref. Compute the suggestion only when import.meta.env.DEV is not statically false, so production Vite builds constant-fold the ternary and dead-code-eliminate closestName and levenshteinDistance (~560 B raw, ~260 B gzip per app). Dev servers, vitest, and Node CLI builds keep the full "Did you mean" messages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
name-suggestions.ts(~776 B raw) shipped in every production client bundle, reachable through unguarded error paths inresolveApp/buildHref. Identified in the 2026-07 client bundle size audit (finding 2).import.meta.env.DEVis not staticallyfalse, so production Vite builds constant-fold the ternary and dead-code-eliminateclosestName/levenshteinDistance. Production errors still list all registered names; dev, vitest, and Node CLI builds keep the full "Did you mean" messages.examples/basic: shared runtime chunk 8.97 → 8.41 kB raw (3.61 → 3.35 kB gzip).Testing
pnpm e2e(80 passed)pnpm formatpnpm lint(viapnpm exec oxlint, 0 errors)pnpm test(605 passed)Checklist
🤖 Generated with Claude Code