Skip to content

refactor: remove lodash dependency and fix @types in prod deps#2252

Open
bjnewman wants to merge 2 commits intorun-llama:mainfrom
bjnewman:e18e/remove-lodash-fix-types
Open

refactor: remove lodash dependency and fix @types in prod deps#2252
bjnewman wants to merge 2 commits intorun-llama:mainfrom
bjnewman:e18e/remove-lodash-fix-types

Conversation

@bjnewman
Copy link
Copy Markdown

@bjnewman bjnewman commented Jan 21, 2026

Summary

  • Remove lodash dependency (~70KB bundle savings) by replacing with native JS:

    • _.isNil(x)x == null
    • _.isObject(x) before instanceof → removed (unnecessary guard)
    • _.values(obj)Object.values(obj)
    • _.get(obj, key, default)obj[key] ?? default
    • _.fromPairs/sortBy/toPairsObject.fromEntries([...Object.entries()].sort())
  • Move @types/node from dependencies to devDependencies in:

    • @llamaindex/core
    • @llamaindex/llamaindex
    • @llamaindex/experimental
  • Remove lodash and @types/lodash from:

    • @llamaindex/llamaindex
    • @llamaindex/experimental
  • Fix MCP test compatibility by updating:

    • @modelcontextprotocol/sdk: ^1.13.0^1.25.3
    • @modelcontextprotocol/server-filesystem: ^2025.7.1^2026.1.14
  • Add native-replacements.test.ts with 28 tests validating native JS equivalents

Motivation

Part of the e18e ecosystem cleanup initiative. This PR:

  1. Reduces bundle size by removing lodash (~70KB)
  2. Fixes incorrect @types/* packages in production dependencies (should be devDependencies)
  3. Uses modern JavaScript features that are well-supported in Node 18+

MCP Version Fix Details

The MCP test (packages/tools/tests/mcp.test.ts) was failing locally with:

ZodError: Invalid literal value, expected "object"
  at path: tools[0].inputSchema.type

Root cause: @modelcontextprotocol/sdk@1.13.0 validates that tool responses include inputSchema.type === "object", but @modelcontextprotocol/server-filesystem@2025.7.1 returns tools without that field.

The version bump to SDK 1.25.3 and server-filesystem 2026.1.14 resolves this compatibility issue. This appears to be a pre-existing issue that was masked by turbo's remote caching (TURBO_REMOTE_ONLY=true in CI).

Test plan

  • All 107 llamaindex tests pass (including 28 new native-replacement tests)
  • All 9 tools tests pass (after MCP version fix)
  • All 8 workflow tests pass
  • Build succeeds for all 53 packages
  • Lint passes

🤖 Generated with Claude Code

- Replace lodash with native JS equivalents:
  - _.isNil(x) → x == null
  - _.isObject(x) before instanceof → removed (unnecessary)
  - _.values(obj) → Object.values(obj)
  - _.get(obj, key, default) → obj[key] ?? default
  - _.fromPairs/sortBy/toPairs → Object.fromEntries/sort

- Move @types/node from dependencies to devDependencies in:
  - @llamaindex/core
  - @llamaindex/llamaindex
  - @llamaindex/experimental

- Remove lodash and @types/lodash from:
  - @llamaindex/llamaindex
  - @llamaindex/experimental

- Fix MCP test compatibility by updating:
  - @modelcontextprotocol/sdk: ^1.13.0 → ^1.25.3
  - @modelcontextprotocol/server-filesystem: ^2025.7.1 → ^2026.1.14

- Add native-replacements.test.ts (28 tests) validating JS behavior

Bundle size reduction: ~70KB from lodash removal
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 21, 2026

🦋 Changeset detected

Latest commit: 8f6a061

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant