Replace five small dependencies with inline equivalents - #381
Merged
Conversation
Each of these was pulled in for one or two trivial call sites:
- lodash: isEqual in BulletedList and capitalize in the Putney Mountain
story. The CJS import meant the full library was bundled, since Next's
default optimizePackageImports covers lodash-es, not lodash.
- uuid: one call generating an id for a log entry that nothing reads.
Replaced with crypto.randomUUID().
- yargs and es6-template-strings: create-story.ts used them to read one
positional arg and interpolate a single ${story} variable. Also drops a
prerelease yargs pin and a @types/yargs that was a major version behind.
Bundle impact is modest: total emitted JS drops 18.8 KB (7.2 KB gzipped).
First Load JS is unchanged, as both call sites sit behind per-story
dynamic imports.
BulletedList previously mapped over the group to emit ' (selected)' per
match, which would repeat for duplicate entries; it now checks membership
once and hoists the loop-invariant array comparison.
Claude-Session: https://claude.ai/code/session_01KZk5VDAZmVzJhMMJipKKHD
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Removes
lodash,uuid,yargs,@types/yargs, andes6-template-strings. Each was pulled in for one or two trivial call sites.isEqualinBulletedList,capitalizein the Putney Mountain story. The CJS import meant the whole library was bundled; Next's defaultoptimizePackageImportslist coverslodash-es, notlodash.idfor a log entry. Nothing incore/,stories/, orpages/ever reads the log slice back, so the value was write-only. Nowcrypto.randomUUID().scripts/create-story.tsused them to read one positional arg and interpolate a single${story}variable. Also drops a^17.0.0-candidate.0prerelease pin and a@types/yargsstuck a major version behind the runtime package.Kept
minimatch(documented in the manual as the matching syntax for<Response>options, so it's a public contract) andjs-yaml.Bundle impact
Measured with an A/B production build off the same tree:
/[story]/[[...chapter]]First LoadFirst Load is unchanged — both lodash call sites sit behind per-story dynamic imports, so it only ever landed in a deferred chunk.
Behavior change
BulletedListpreviously mapped overgroupand returned' (selected)'for each match, which would render the string more than once if a group contained duplicate entries. It now checks membership once, and the loop-invariant array comparison is hoisted out of the inner map.Verification
npm run test(7 passed),eslint, andtsc --noEmitall clean.npm run newverified to generate all four templates with correct interpolation, plus the missing-argument error path.https://claude.ai/code/session_01KZk5VDAZmVzJhMMJipKKHD