Skip to content

Conversation

@Tobbe
Copy link
Member

@Tobbe Tobbe commented Jan 5, 2026

Follow-up on #939 and following the guidelines here https://lodash.com/per-method-packages they ask you to do const throttle = require('lodash/throttle'). The ESM version of that is import throttle from lodash/throttle.js`. So that's what I'm doing everywhere.

@netlify
Copy link

netlify bot commented Jan 5, 2026

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit d92a2c6
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/695b900175adf30008b2de3e

@github-actions github-actions bot added this to the next-release-patch milestone Jan 5, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 5, 2026

Greptile Summary

This PR updates all lodash imports across the codebase to use ESM-compatible syntax by importing individual functions from their respective files with .js extensions (e.g., import memoize from 'lodash/memoize.js'). This change is necessary because the codebase has been migrated to ESM modules (indicated by "type": "module" in package.json), and lodash v4.17.21 requires this import pattern for proper ESM support. All changes are consistent across 8 files touching CLI, GraphQL server, and structure packages, plus documentation updates.

Changes made:

  • Replaced default lodash imports with individual ESM imports from specific function paths
  • Removed intermediate destructuring patterns (e.g., const { func } = lodash)
  • Updated all usage sites to reference the imported function directly
  • Updated documentation example to reflect new import pattern
  • No functional logic changes; purely import statement refactoring for ESM compatibility

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues. All lodash imports have been correctly updated for ESM compatibility.
  • Score of 5 reflects that this is a straightforward, well-executed import refactoring with no functional changes. All 8 files show consistent patterns, all usage sites are correctly updated, and the changes align with the codebase's ESM migration. No breaking changes, no logic modifications, and no potential runtime issues. The PR successfully addresses ESM compatibility for lodash across multiple packages.
  • No files require special attention. All changes are correct and consistent.

Important Files Changed

Filename Overview
packages/cli/src/commands/dev/tests/dev.test.ts Updated lodash find import from named import to ESM-compatible deep import with .js extension. Correct for ESM modules.
packages/cli/src/lib/index.js Replaced default lodash import with individual ESM imports for memoize and template. Removed destructuring pattern. Changes are correct for ESM.
packages/cli/src/lib/merge/strategy.js Updated lodash default import to direct ESM import of uniqWith function. All usages of _.uniqWith correctly changed to uniqWith. No functional changes.
packages/graphql-server/src/makeMergedSchema.ts Replaced default lodash import with ESM imports for merge and omitBy. Removed destructuring. All usage sites updated correctly.
packages/structure/src/model/RWEnvHelper.ts Updated lodash pickBy import to ESM format. Single function import, straightforward change.
packages/structure/src/x/diagnostics.ts Updated lodash imports from named import to three separate ESM imports (groupBy, mapValues, uniqBy). All changes are correct for ESM.
packages/structure/src/x/ts-morph.ts Updated lodash memoize import from named import to ESM direct import. Correct for ESM modules.
upgrade-scripts/README.md Updated documentation example to show ESM import pattern. Reflects the new import style for the codebase.

Sequence Diagram

sequenceDiagram
    participant Module as ESM Module
    participant Lodash as lodash Package
    participant Func as Function Export
    
    Module->>Lodash: Before: import { func } from 'lodash'
    Lodash->>Module: CommonJS default export (not ideal for ESM)
    
    Module->>Lodash: After: import func from 'lodash/func.js'
    Lodash->>Func: Resolves to ESM function file
    Func->>Module: Returns ESM export (proper ESM support)
    
    Note over Module,Func: ESM-compatible import pattern

Loading

@nx-cloud
Copy link

nx-cloud bot commented Jan 5, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit d92a2c6

Command Status Duration Result
nx run-many -t test --minWorkers=1 --maxWorkers=4 ✅ Succeeded 2m 56s View ↗
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 33s View ↗
nx run-many -t build ✅ Succeeded 2m 11s View ↗
nx run-many -t test:types ✅ Succeeded 9s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-05 10:38:02 UTC

@Tobbe Tobbe merged commit ab585c8 into main Jan 5, 2026
42 checks passed
@Tobbe Tobbe deleted the tobbe-fix-lodash-imports branch January 5, 2026 10:38
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.

2 participants