Skip to content

refactor: remove all three runtime dependencies - #212

Merged
Eliav2 merged 1 commit into
mainfrom
refactor/drop-runtime-deps
Aug 8, 2026
Merged

refactor: remove all three runtime dependencies#212
Eliav2 merged 1 commit into
mainfrom
refactor/drop-runtime-deps

Conversation

@Eliav2

@Eliav2 Eliav2 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Closes #118. Supersedes #175.

The package now declares no runtime dependencies at all, only a React peer.

-"dependencies": { "@types/prop-types": "^15.7.3", "lodash": "^4.17.21", "prop-types": "^15.7.2" }
+"dependencies": {}

lodash

Three call sites, two functions.

_.pick(o, ["x","y"]) became an object literal, twice.

_.isEqual is the interesting one. It is only ever reached from the two effects that track element positions, and getElemPos always returns { x, y, right, bottom }, including on its null-element branch. So the "deep compare" was comparing four numbers.

That killed the obvious plan. v3 (dev-back-to-life) swapped lodash for react-fast-compare, and copying that would have replaced one unnecessary dependency with another. An explicit field comparison is exact here, and avoids a general deep-equal having to be careful around the refs and React elements that appear elsewhere in the props.

prop-types

Dead weight on React 19, which dropped support for it. Measured rather than assumed:

mentions of propTypes in the dev runtime
React 18 19
React 19 0

It only ever produced dev-time warnings for JavaScript consumers on React 16.8 to 18. TypeScript users already get the same checks at compile time. This is the one change that removes a real capability, small as it is.

@types/prop-types

Declared as a runtime dependency, never imported in src, and absent from the emitted declarations. Every consumer has been installing it for nothing. @types/lodash goes with lodash.

Sizes

before after
ESM 22.80 kB (gzip 7.45) 21.47 kB (7.07)
CJS 18.50 kB 16.89 kB (6.43)
UMD 18.71 kB 17.06 kB (6.52)

That understates the real win: lodash was external, so consumers were resolving the whole of it from their own tree.

Verification

Behaviour is unchanged. Rendered five prop combinations against the main build and this one and diffed the markup: byte identical.

It actually works without them installed. Packed the tarball into a fresh project with neither lodash nor prop-types present and loaded all three formats: ESM, CJS, and UMD with React as the only global.

react is now the only external, and CI's UMD smoke test supplies only React, so a regression that reintroduced a runtime dependency would fail there.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved position-change detection for more predictable arrow updates.
    • Preserved endpoint calculations while simplifying internal comparisons.
  • Chores

    • Removed runtime PropTypes support and related validation metadata.
    • Removed lodash and PropTypes runtime dependencies.
    • Updated library builds to rely only on the React global in UMD environments.

Closes #118. Supersedes #175.

The package now declares no runtime dependencies at all, only a React peer.

lodash was three call sites and two functions:
- _.pick(o, ['x','y']) became an object literal, twice.
- _.isEqual is only ever reached from the two effects that track element
  positions, and getElemPos always returns { x, y, right, bottom }, including on
  its null-element branch. So the deep comparison was comparing four numbers.
  Replaced with an explicit field comparison rather than another dependency:
  v3 swapped lodash for react-fast-compare, but v2 does not need even that, and
  a general deep-equal would also have to be careful around the refs and React
  elements that appear elsewhere in the props.

prop-types is dead weight on React 19, which dropped support for it: its dev
runtime mentions propTypes zero times, against 19 in React 18. It only ever
provided dev-time warnings for JavaScript consumers on React 16.8 to 18, and
TypeScript users already get the same checks at compile time.

@types/prop-types was declared as a runtime dependency, is never imported in
src, and does not appear in the emitted declarations, so every consumer has
been installing it for nothing. @types/lodash goes with lodash.

react is now the only external, so a script-tag consumer needs nothing else.
CI's UMD smoke test supplies only React, which would catch a regression that
reintroduced a runtime dependency.

Sizes, minified:
  ESM  22.80 -> 21.47 kB   gzip 7.45 -> 7.07
  CJS  18.50 -> 16.89 kB   gzip 6.43
  UMD  18.71 -> 17.06 kB   gzip 6.52
That understates it: lodash was external, so consumers were resolving it from
their own tree.

Behaviour verified rather than assumed. Rendered five prop combinations against
the main build and this one and diffed: byte identical. Packed the tarball and
loaded ESM, CJS and UMD in a project with neither lodash nor prop-types
installed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codesandbox

codesandbox Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploy Preview for react-xarrows ready!

Name Link
🔨 Latest commit 10384a8
🔍 Latest deploy log https://app.netlify.com/projects/react-xarrows/deploys/6a77a7711fa6e60008a76556
😎 Deploy Preview https://deploy-preview-212--react-xarrows.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR removes Lodash and PropTypes from runtime code, package dependencies, and UMD configuration. Position comparisons now inspect only relevant coordinates. The CI UMD sandbox provides only React and console.

Changes

Runtime dependency cleanup

Layer / File(s) Summary
Position comparison and endpoint updates
src/Xarrow/useXarrowProps.ts, src/Xarrow/utils/GetPosition.tsx
Position memoization now compares position dimensions directly. Endpoint objects are created without Lodash.
PropTypes removal
src/Xarrow/Xarrow.tsx, src/Xarrow/propTypes.ts
The component no longer imports or exposes runtime PropTypes metadata.
Package and UMD configuration
package.json, vite.config.mts, .github/workflows/ci.yml
Lodash and PropTypes dependencies and external mappings were removed. The UMD verification sandbox now provides only React and console.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Removing PropTypes and its type dependency is not required by linked issue #118, which only addresses lodash bundling. Link an issue covering PropTypes removal, or limit this PR to the lodash-related changes in issue #118.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: removing the package's three runtime dependencies.
Linked Issues check ✅ Passed The PR removes lodash imports, replaces its utilities, and updates build externals, satisfying issue #118.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/drop-runtime-deps

Comment @coderabbitai help to get the list of available commands.

@Eliav2
Eliav2 merged commit 7465ae5 into main Aug 8, 2026
5 of 6 checks passed
@Eliav2
Eliav2 deleted the refactor/drop-runtime-deps branch August 8, 2026 22:08

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Xarrow/useXarrowProps.ts`:
- Around line 307-318: Update usePositionEffect to use primitive coordinate
dependencies directly instead of mapping through usePositionMemoize: pass
startPos.x, startPos.y, startPos.right, and startPos.bottom, and apply the
equivalent four dependencies for endPos at each call site. Remove
usePositionMemoize and samePosition once no longer referenced, preserving the
existing useLayoutEffect behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7864739e-e5e7-4590-a43d-a3e483492f29

📥 Commits

Reviewing files that changed from the base of the PR and between 761c4ed and 10384a8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • package.json
  • src/Xarrow/Xarrow.tsx
  • src/Xarrow/propTypes.ts
  • src/Xarrow/useXarrowProps.ts
  • src/Xarrow/utils/GetPosition.tsx
  • vite.config.mts
💤 Files with no reviewable changes (3)
  • src/Xarrow/propTypes.ts
  • package.json
  • src/Xarrow/Xarrow.tsx

Comment thread src/Xarrow/useXarrowProps.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Entirety of Lodash is Bundled (over 75% of package size)

1 participant