chore: dependency diet — remove 10 dead/duplicated deps and 800 lines of vendored code#1410
Open
UditDewan wants to merge 1 commit into
Open
chore: dependency diet — remove 10 dead/duplicated deps and 800 lines of vendored code#1410UditDewan wants to merge 1 commit into
UditDewan wants to merge 1 commit into
Conversation
Deletes dependencies that were unused, deprecated, or duplicating
functionality already present in the stdlib, the platform, or another
installed dependency. Net -813 lines. No functional changes intended;
see PR description for the full per-change risk analysis.
- delete unused deps: google-ads-api, recharts, stopwatch-node, @types/pg-promise
- cuid -> juava randomId() (cuid is deprecated upstream)
- use-debounce -> local 6-line useDebouncedValue hook
- react-use -> local 3-line useTitle hook
- @loadable/component -> next/dynamic
- timezones-list -> Intl.supportedValuesOf("timeZone")
- object-hash -> juavaHash("md5", stableHash(...)) (existing in-repo idiom)
- delete juava/src/debounce.ts (130-line vendored lodash debounce) ->
4-line resettable setTimeout in singleton.ts
- juava deepCopy -> structuredClone one-liner
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.
Dependency diet: remove 10 dead/duplicated deps and 800 lines of vendored code
TL;DR
webapps/console×10 lines,cli/jitsu-cli×1 —cuidcounted once)tsc --noEmitclean on console, rotor, jitsu-cli; juava builds; prettier clean; runnable smoke checks passThis PR came out of a whole-repo over-engineering audit. Every removal below was verified by grepping all workspaces (
webapps,libs,services,cli) for import sites before touching anything, and every replacement was re-typechecked afterwards.1. Dead dependencies — deleted outright (zero call sites)
google-ads-api^17.1.0-rest-betarecharts^2.10.4chart.jsis the charting library actually used (BillingDetails,EventStatPage). Two chart libs were installed; one was never imported.stopwatch-node^1.1.0stopwatch.ts, which is what the code actually uses.@types/pg-promise^5.4.3pg-promiseitself is not a dependency and is never importedpg+pg-cursor. This was a types stub for a library that isn't installed.Risk: none. Nothing imports these; removal only shrinks
node_modulesand the lockfile.2.
cuid→ juavarandomId()— 3 call siteswebapps/console/components/ConfigObjectEditor/ConfigEditor.tsx(new config object ids, ×2)webapps/console/pages/[workspaceId]/settings/domains.tsx(new domain ids)cli/jitsu-cli/src/commands/deploy.ts(new function ids on deploy)Why:
cuidis deprecated by its author (recommends cuid2). The repo already has its own id generator —randomId()fromjuava— used everywhere else for the same purpose (includingconfig-objects-service.ts, which creates the same kinds of objects server-side). One id scheme is enough.Behavior note: newly created objects get 24-char alphanumeric ids (juava format) instead of 25-char
c…cuid format. Existing ids are untouched and never re-validated: a repo-wide grep found no format validation anywhere (ids are opaque strings in Prismatextcolumns). jitsu-cli already depends onjuava(workspace:*), so no new dependency edge was created.3.
use-debounce→ 6-lineuseDebouncedValuehookBoth call sites (
AuditLog.tsx,workspaces.tsx) used exactly one shape:const [v] = useDebounce(value, ms)— debouncing a value, not a callback. That is asetTimeout/clearTimeoutpair in an effect:Added to
webapps/console/lib/ui.tsxnext to the other shared hooks. Identical trailing-edge semantics for this usage; none ofuse-debounce's extra options (leading, maxWait, equality fn) were used.4.
react-use→ 3-lineuseTitleThe entire
react-usedependency existed for one hook,useTitle, imported in one file (lib/ui.tsx) and re-exported. All six call sites pass a plain string and none userestoreOnUnmount. Replaced with:5.
@loadable/component→next/dynamicOne call site,
DataView/JSONView.tsx, lazy-loadingreact-json-view. This is a Next.js app;next/dynamicis the framework-native way to do exactly this, including skipping SSR (react-json-viewis browser-only):The old code wrapped the import in a hand-built
new Promise((r, c) => …)to unwrap.default—next/dynamicdoes that unwrapping itself.6.
timezones-list→Intl.supportedValuesOf("timeZone")One call site: the sync scheduler timezone
<Select>inSyncEditorPage.tsx. The platform ships the timezone database; a static npm copy of it goes stale. Replacement builds the same{ value, label }shape with a native GMT-offset label:Behavior notes, checked explicitly:
timeZoneNamepart, every label matches/GMT([+-]\d{2}:\d{2})?\)$/. Module-level evaluation cannot throw.Asia/CalcuttavsAsia/Kolkata) depending on engine/version. Every returned name is a valid IANA identifier, which is all the scheduler backend (cron-parser) requires.Selectshows the raw value when no option matches.Etc/UTC(not in the ICU list) remains explicitly prepended as the default option, unchanged.7.
object-hash→juavaHash("md5", stableHash(...))Two files imported
object-hash; one of them (pages/api/admin/export/[name]/index.ts) imported bothobject-hashandstable-hashand — at line 916 — already used the exact idiom this PR standardizes on:juavaHash("md5", stableHash(x)). Now the whole file uses one hashing scheme via a 1-line localhashhelper;tasks.tsx(aReact.memoprop comparator, purely ephemeral) usesstableHashequality directly.Behavior note — hash values change once, verified safe: the
optionsHash/credentialsHash/codeHashfields emitted by the admin export API change value on the first deploy (sha1-of-object-hash → md5-of-stable-hash). Traced every downstream consumer before making this change:services/rotor/src/lib/warehouse-store.ts— key of an in-memory singleton map (${con.id}-${con.credentialsHash})services/rotor/src/lib/message-handler.ts,functions-server.ts— in-memory UDF cache keysbulker/operator/types.go— passthrough struct fields, never compared against stored valuesAll are cache keys that already miss on every process restart. Effect of the switch: one extra cache refresh on the first deploy, then steady state. Nothing persists or replays old hash values. Important:
stable-hashoutput alone is a serialization (would leak credentials incredentialsHash) — that's why it is always wrapped injuavaHash("md5", …), never used raw for these fields.8. juava
debounce.ts(130 lines) → 4-line resettable timerlibs/juava/src/debounce.tswas a vendored copy of lodash'sdebounce, not exported from the package index, with exactly one internal consumer:singleton.tsused it as a resettable TTL timer (every singleton access postpones cleanup tottlSecafter the last access). That is:Trailing-edge semantics preserved exactly (verified:
debounceCleanupis only ever called —.cancel()/.flush()/.pending()were never used). The 130-line file is deleted.9. juava
deepCopy→structuredCloneone-linerdeepCopyhad exactly one real consumer:config-objects-service.ts:283, copying a Prisma JSON config column (JSON-safe by construction).structuredCloneis native in Node 17+ and all browsers since 2022.Semantics documented at the definition:
structuredClonethrows on functions in the tree (the old copy silently copied them by reference) and correctly clonesDates (the old copy mangled them into{}— arguably a latent bug). Callers must pass JSON-safe data; the one existing caller does.Deliberately NOT deduplicated:
services/rotor/src/lib/udf-chain.tskeeps its own localdeepCopy. Its file header forbids importing juava — the module is bundled into a permission-less Deno sandbox worker, and juava's index pulls inprocess, logging, and ClickHouse client code. Aponytail:comment now records why the duplicate is intentional. Same forlibs/jitsu-js/src/analytics-plugin.ts(standalone browser SDK, own copy, untouched).Verification
pnpm --filter @jitsu-internal/console run typecheckpnpm --filter rotor run typecheckpnpm --filter jitsu-cli run typecheckpnpm --filter juava run buildpnpm install--checkwebapps,libs,services,clistructuredCloneparity vs olddeepCopyon nested data; timezone mapper over all 418 ICU zones; resettable-timer debounce semantics (3 rapid calls → 1 firing)Explicitly out of scope (audited, deliberately skipped)
lib/server/templates.tsxon mjml,emails/on react-email). Cutting mjml is a real template migration touching production email rendering — separate PR.libs/jsondiffpatchvendored fork (654 lines). Consumed byjitsu-jsandrotor. Replacing it with upstreamjsondiffpatch@0.6.0requires diffing the fork against upstream first to rule out local patches.isEqual/collections.ts→ lodash. juava does not currently depend on lodash; adding a dependency edge to delete 26 lines is a net loss.firebase/@types/cookie/ other low-confidence candidates — not conclusively dead, left alone.Rollback
Single commit, no data migrations, no persisted-format changes (new-id format and hash values are forward-only but non-breaking, as analyzed above).
git revertrestores everything, including the deleteddebounce.ts.