perf(build): expand lib stub pattern to cover unused transitive externals#599
Closed
John-David Dalton (jdalton) wants to merge 1 commit intomainfrom
Closed
perf(build): expand lib stub pattern to cover unused transitive externals#599John-David Dalton (jdalton) wants to merge 1 commit intomainfrom
John-David Dalton (jdalton) wants to merge 1 commit intomainfrom
Conversation
…nals The current createLibStubPlugin already stubs socket-lib's globs.js, sorts.js, and the npm-pack / pico-pack external bundles since none of their code paths are exercised by the SDK's runtime. Extend the same pattern to two more transitive externals: - @socketsecurity/lib/dist/external/del.js — pulled in by fs.js's lazy getDel() for safeDelete/safeDeleteSync. The SDK only uses validateFiles() from fs and never deletes. - @socketsecurity/lib/dist/external/cacache.js — destructures from npm-pack (already stubbed), so the eager require would already yield undefined. Stubbing makes the intent explicit. Result on dist/index.js: 712,442 → 711,934 bytes (−508 bytes). Modest gain since socket-lib's own stubs (v5.19.0 +) cascade here automatically once the lib dep bumps. Full vitest suite runs with same pass/fail counts as main (739 passing; 1 pre-existing .claude/hooks failure unrelated to this change).
Contributor
Author
|
Rolled into #596 alongside the socket-lib 5.19.0 bump — consolidating the cascade work into one PR. |
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
createLibStubPluginin.config/esbuild.config.mtsto additionally stub@socketsecurity/lib/dist/external/del.jsand@socketsecurity/lib/dist/external/cacache.js@socketsecurity/lib/dist/fs.js(via lazygetDel()) and by@socketsecurity/lib/dist/cacache.js(destructures from already-stubbednpm-pack), but the SDK never callssafeDelete/safeDeleteSyncand itscache-with-ttlpath degrades gracefullyResult
dist/index.js: 712,442 → 711,934 bytes (−508 bytes)Modest on its own; the larger win flows from upstream socket-lib 5.19.0, which adds ~14 new stubs (sigstore/tuf/arborist internals) that cascade into the SDK's bundle automatically on the next lib bump.
Test plan
pnpm run buildsucceeds, emits type declarationspnpm exec vitest runshows same pass/fail counts asmain(739 passing; 1 pre-existing.claude/hooks/check-new-depsfailure unrelated to this change)