Skip to content

Conversation

@sumitparakh
Copy link

Problem

The ember-vite-codemod currently cannot correctly locate dependencies when an Ember app or addon is part of a Yarn workspace (monorepo). This causes:

  • False positives when checking for v1 addons and their availability
  • Difficulty upgrading to the latest Ember versions
  • Issues migrating build configuration to Vite in monorepo setups

The root cause is that in Yarn workspaces, dependencies are hoisted to the workspace root's node_modules directory, but the codemod was only looking in the app's local directory.

Solution

This PR adds a new --yarn-workspace CLI option that enables proper dependency resolution in monorepo environments.

Changes:

  • Added --yarn-workspace CLI flag to indicate the app is part of a Yarn workspace
  • Created lib/utils/find-yarn-workspace.js utility to locate the workspace root by traversing up the directory tree and finding the workspace's package.json
  • Updated lib/tasks/ensure-v2-addons.js to:
    • Accept a yarnWorkspace parameter
    • Check both the app's local node_modules and the workspace root's node_modules when resolving dependencies
    • Correctly determine addon versions and availability in monorepo setups
  • Updated documentation in README.md to explain the new option and its usage

Usage:

npx ember-vite-codemod@latest --yarn-workspace

- Introduced `--yarn-workspace` option to the codemod CLI.
- Implemented `findYarnWorkspaceRoot` utility to locate Yarn workspace root.
- Updated `getV1Addons` function to handle Yarn workspace dependencies.
Copilot AI review requested due to automatic review settings November 10, 2025 14:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds Yarn workspace (monorepo) support to help the codemod correctly locate dependencies in workspace environments where node_modules may be hoisted to the workspace root.

Key changes:

  • New findYarnWorkspaceRoot() utility function to recursively search for workspace root
  • Added --yarn-workspace CLI option to enable workspace-aware dependency resolution
  • Modified dependency lookup to use workspace root path when in a workspace

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
lib/utils/find-yarn-workspace.js New utility function to locate Yarn workspace root by walking up directory tree
lib/tasks/ensure-v2-addons.js Updated dependency resolution to support workspace root paths when --yarn-workspace is enabled
index.js Added new --yarn-workspace CLI option
README.md Documented the new --yarn-workspace option in the options table

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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