Skip to content

Faster startup (3/4): Inline app-init and hydrogen-init hooks#7053

Draft
gonzaloriestra wants to merge 1 commit intofaster-startup-2from
faster-startup-3
Draft

Faster startup (3/4): Inline app-init and hydrogen-init hooks#7053
gonzaloriestra wants to merge 1 commit intofaster-startup-2from
faster-startup-3

Conversation

@gonzaloriestra
Copy link
Contributor

WHY are these changes introduced?

The CLI requires too much time to start working, it feels slow

WHAT is this pull request doing?

Replaces the re-export hook stubs from PR 1/4 with inlined implementations that avoid loading heavy package dependency chains.

  • Inlined app-init.ts: lazily imports LocalStorage instead of pulling in the entire @shopify/app chain (~1s of imports). Uses Node's native crypto.randomUUID() instead of importing from cli-kit
  • Inlined hydrogen-init.ts: skips loading @shopify/cli-hydrogen entirely for non-hydrogen commands (~300ms+ saved). Only loads the module when options.id starts with hydrogen:

Startup time: 710ms → 530ms (-25%)

How to test your changes?

  • shopify app dev still initializes correctly (LocalStorage cleared, run ID set)
  • shopify hydrogen dev still runs hydrogen init hook
  • Non-hydrogen commands skip hydrogen module loading

Measuring impact

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Made with Cursor

Copy link
Contributor Author

gonzaloriestra commented Mar 19, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Replace re-exports from @shopify/app and @shopify/cli-hydrogen with
inlined versions. app-init now lazily imports LocalStorage instead of
pulling the entire @shopify/app chain (~1s). hydrogen-init skips loading
@shopify/cli-hydrogen entirely for non-hydrogen commands (~300ms).

Startup time: 710ms → 530ms (-25%)

Made-with: Cursor
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