Draft
Conversation
Contributor
|
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
3 tasks
isaacroldan
approved these changes
Mar 5, 2026
Contributor
isaacroldan
left a comment
There was a problem hiding this comment.
If this allows us to remove all the code to detect the hydrogen monorepo and load the plugin from the CLI repo, then great! love it!
It makes more sense for you to own this part :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Replaces: Shopify/cli#6827
Since
@shopify/cli@3.83.0(which upgraded oclif to v4), runningshopify hydrogencommands in the Hydrogen monorepo no longer loads the localpackages/clisource code. Instead, the bundled version inside@shopify/cli/distis always used, making it impossible to test local CLI changes during development.Root cause: The previous mechanism in
@shopify/cli-kit'sShopifyConfigrelied on overriding oclif'sdeterminePriorityinstance method to make external plugin commands win over bundled ones. In oclif v4 (shipped in@shopify/cli@3.83.0),determinePrioritybecame a standalone utility function, so the override silently stopped working. Additionally, the monorepo detection itself is not the best:/(shopify|hydrogen)\/hydrogen/itested againstcwd()to guess if you're in the monorepoexecSync('npm', ['prefix'])on every CLI invocation to find the project rootdeterminePrioritymethodThis PR introduces a self-contained patch system within the Hydrogen monorepo that replaces all of that.
WHAT is this pull request doing?
Adds two scripts that enable local CLI development:
scripts/patch-cli.mjs— Patchesnode_modules/@shopify/cli/bin/run.jsto load the local@shopify/cli-hydrogenplugin frompackages/cliinstead of the bundled version. The patch:cwd()looking forpackages/cli/package.json— no regex, no subprocessespluginAdditionsmechanism to register the local@shopify/cli-hydrogenas a core plugin, the same mechanismShopifyConfiguses internally_commandsMap and re-inserting them from the local plugin vialoadCommands()— this is the same strategy proposed in the upstream CLI fix (Fix custom-oclif-loader.ts hydrogen loader strategy for hydrogen-cli local development cli#6827) and works with oclif v4IGNORE_HYDROGEN_MONOREPO=1so the currentShopifyConfigin@shopify/cli-kitdoesn't attempt its own (broken) monorepo detection on top (NOTE: We can remove this if we update thecustom-oclif-loaderto become purely for letting users overridecli-hydrogenwith a different version from their project'snode_modules.)patch-packagesorpnpm patchscripts/unpatch-cli.mjs— Restoresrun.jsto its original content. Also idempotent.How the patch interacts with the CLI plugin architecture:
For non-hydrogen commands or when running outside the monorepo, the standard
@shopify/clientrypoint is used unchanged.Upstream impact: This patch is can replace Shopify/cli#6827, which fixes the
custom-oclif-loaderfor local@shopify/cli-hydrogendevelopment in the monorepo. Thecustom-oclif-loadercan be simplified to remove all monorepo-specific logic (regex,npm prefix,IGNORE_HYDROGEN_MONOREPO), since this patch handles that case entirely within the Hydrogen repo.HOW to test your changes?
pnpm install(orpnpm patch-cliif already installed)packages/cli/src/commands/hydrogen/dev.ts(e.g. add aconsole.log('test')in therun()method)pnpm run build --filter=@shopify/cli-hydrogentemplates/skeleton, runnpx shopify hydrogen devhydrogen-monorepobanner appearsconsole.logfrom step 2 is printedpnpm unpatch-cliand repeat step 4 — the banner should not appear and your change should not be visible (bundled version is used)Checklist