Skip to content

refactor: remove ESBuildContextManager from app-event-watcher#7252

Open
isaacroldan wants to merge 1 commit intomainfrom
04-13-refactor_remove_esbuildcontextmanager_from_app-event-watcher
Open

refactor: remove ESBuildContextManager from app-event-watcher#7252
isaacroldan wants to merge 1 commit intomainfrom
04-13-refactor_remove_esbuildcontextmanager_from_app-event-watcher

Conversation

@isaacroldan
Copy link
Copy Markdown
Contributor

@isaacroldan isaacroldan commented Apr 13, 2026

We originally added ESBuildContextManageras a faster way to re-build UI extensions -> by keeping in memory esbuild contexts, re-builds are faster.

This was at the expense of having a custom build pipeline in the app watcher just for ui extensions. This is now causing issues because ui-extensions are not following the standard build flow and therefore not running all "build steps".

This PR removes ESBuildContextManagerand brings back ui-extensions to be compiled like the rest of extensions:

  • Simplifies the dev watcher pipeline — one build path instead of two.
  • Reduces surface area — ~375 lines of code and tests deleted.
  • Makes the watcher easier to reason about — no need to track which extensions use esbuild contexts vs. the default build path.

The benefit of this manager is negligible for small extensions (we might save single digit miliseconds)

Copy link
Copy Markdown
Contributor Author

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

@isaacroldan isaacroldan marked this pull request as ready for review April 13, 2026 10:48
@isaacroldan isaacroldan requested a review from a team as a code owner April 13, 2026 10:48
Copilot AI review requested due to automatic review settings April 13, 2026 10:48
@isaacroldan isaacroldan force-pushed the 04-13-refactor_remove_esbuildcontextmanager_from_app-event-watcher branch from 1c759aa to 514b959 Compare April 13, 2026 10:49
Copy link
Copy Markdown
Contributor

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

Removes the custom esbuild-context-based build path from the app dev watcher so UI extensions go through the same “standard” build pipeline (and therefore run the same build steps) as other extension types.

Changes:

  • Deleted ESBuildContextManager and its dedicated tests.
  • Simplified AppEventWatcher to always build extensions via extension.buildForBundle().
  • Updated watcher tests to no longer mock/inject the esbuild manager and to simulate errors via the standard build path.

Reviewed changes

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

File Description
packages/app/src/cli/services/dev/app-events/app-watcher-esbuild.ts Removed the custom esbuild context manager implementation.
packages/app/src/cli/services/dev/app-events/app-watcher-esbuild.test.ts Removed tests tied to the esbuild context manager behavior.
packages/app/src/cli/services/dev/app-events/app-event-watcher.ts Dropped the esbuild-manager branch and unified extension builds under buildForBundle().
packages/app/src/cli/services/dev/app-events/app-event-watcher.test.ts Updated tests to match the unified build path; removed esbuild-manager mocking.
Comments suppressed due to low confidence (5)

packages/app/src/cli/services/dev/app-events/app-event-watcher.test.ts:404

  • There’s trailing whitespace on this blank line, which will likely fail formatting/linting (Prettier/no-trailing-spaces). Please remove the spaces so it’s an empty line.
          if (needsAppReload) {

packages/app/src/cli/services/dev/app-events/app-event-watcher.test.ts:441

  • There’s trailing whitespace on this blank line, which will likely fail formatting/linting (Prettier/no-trailing-spaces). Please remove the spaces so it’s an empty line.
        // Then

packages/app/src/cli/services/dev/app-events/app-event-watcher.test.ts:478

  • There’s trailing whitespace on this blank line, which will likely fail formatting/linting (Prettier/no-trailing-spaces). Please remove the spaces so it’s an empty line.
    })

packages/app/src/cli/services/dev/app-events/app-event-watcher.test.ts:512

  • There’s trailing whitespace on this blank line, which will likely fail formatting/linting (Prettier/no-trailing-spaces). Please remove the spaces so it’s an empty line.
    })

packages/app/src/cli/services/dev/app-events/app-event-watcher.test.ts:603

  • There’s trailing whitespace on this blank line, which will likely fail formatting/linting (Prettier/no-trailing-spaces). Please remove the spaces so it’s an empty line.
          type: 'file_updated',

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

Comment on lines 239 to 242
return useConcurrentOutputContext({outputPrefix: ext.handle, stripAnsi: false}, async () => {
try {
if (this.esbuildManager.contexts?.[ext.uid]?.length) {
await this.esbuildManager.rebuildContext(ext)
const sizeInfo = await formatBundleSize(ext.outputPath)
this.options.stdout.write(`Build successful${sizeInfo}`)
} else {
await this.buildExtension(ext)
}
await this.buildExtension(ext)
// Update all events for this extension with success result
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

With the ESBuildContextManager path removed, UI extensions now build via extension.buildForBundle(). The UI bundling step (buildUIExtension) currently catches esbuild failures and rethrows an AbortError without preserving the original error.errors payload, so this watcher’s esbuild-specific formatting branch won’t run and users may only see a generic message. Consider propagating the underlying esbuild errors array on the thrown error (similar to buildFunctionExtension) so dev watcher output remains actionable.

Copilot uses AI. Check for mistakes.
Comment on lines 285 to 289
/**
* Build a single non-esbuild extension using the default buildForBundle method.
* Build a single extension using the default buildForBundle method.
* @param extension - The extension to build
*/
private async buildExtension(extension: ExtensionInstance): Promise<void> {
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

Now that UI extensions build through the standard buildForBundle flow, dev builds appear to always minify UI bundles (buildUIExtension hard-codes minify: true). That means the documented SHOPIFY_CLI_DISABLE_MINIFICATION_ON_DEV opt-out no longer has any effect. Please ensure dev builds still honor that env var (e.g., by making UI bundling’s minify conditional when environment === 'development').

Copilot uses AI. Check for mistakes.
@isaacroldan isaacroldan force-pushed the 04-13-refactor_remove_esbuildcontextmanager_from_app-event-watcher branch 2 times, most recently from 0c96318 to 72a27a8 Compare April 13, 2026 11:04
Co-authored-by: Claude Code <claude-code@anthropic.com>
@isaacroldan isaacroldan force-pushed the 04-13-refactor_remove_esbuildcontextmanager_from_app-event-watcher branch from 72a27a8 to acf912a Compare April 13, 2026 11:09
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