Skip to content

Replace lodash imports with native JavaScript equivalents #485

Description

@georgeolaru

Context

As part of the WordPress 7.0 compatibility effort (#481), we identified that Nova Blocks imports lodash utilities (pick, mapValues, isEqual, omit, merge, etc.) across many files.

Current state

  • lodash is still bundled in WP 7.0 beta 2 (deprecated but not removed)
  • WordPress has been deprecating lodash since WP 5.8 and recommends native JS alternatives
  • Removal is expected in a future WP major version

What needs to happen

  1. Audit all lodash imports across Nova Blocks packages
  2. Replace each with native JS equivalents:
    • pick(obj, keys)Object.fromEntries(keys.filter(k => k in obj).map(k => [k, obj[k]]))
    • mapValues(obj, fn)Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, fn(v)]))
    • isEqualJSON.stringify for simple cases, or a small deep-equal utility
    • omit(obj, keys) → destructuring or Object.fromEntries(Object.entries(obj).filter(...))
    • merge → structured clone + spread, or a small deep-merge utility
  3. Remove lodash from webpack externals if no imports remain
  4. Test all affected blocks

Why it was deferred

  • lodash is still bundled in WP 7.0, so this is not breaking
  • Replacing across many files carries risk of subtle behavioral differences
  • Better done as a focused cleanup effort

Reference

  • Wave 4 plan: plans/2026-03-02-nova-blocks-wave4-package-replacements.md (in anima repo)
  • Parent WP7 plan: plans/2026-03-02-wordpress-7-compatibility.md (in anima repo)
  • Related: #481

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions