Skip to content

Watch asset directories for changes during dev#7470

Open
melissaluu wants to merge 1 commit intomainfrom
05-05-add-directories-to-watched-files
Open

Watch asset directories for changes during dev#7470
melissaluu wants to merge 1 commit intomainfrom
05-05-add-directories-to-watched-files

Conversation

@melissaluu
Copy link
Copy Markdown
Contributor

@melissaluu melissaluu commented May 5, 2026

WHY are these changes introduced?

When an extension's build step copies assets from a source directory (e.g., static_root, schema_path), changes to files inside those directories were not being picked up by the file watcher during dev. This meant that adding an asset image would not trigger a rebuild or hot-reload.

WHAT is this pull request doing?

Introduces a mechanism for ExtensionInstance to track additional watched paths beyond its source imports, and wires it into the file watcher and build pipeline:

  • Adds addWatchedPath, getWatchedPaths, and clearWatchedPaths methods to ExtensionInstance. Paths are stored in a deduplicated Set and are included in the output of watchedFiles().
  • In executeIncludeAssetsStep, directory-type asset sources are registered as watched paths on the extension after being copied, so the watcher knows to monitor them.
  • In FileWatcher, the extensionWatchedFiles map now tracks both files and directories. A new getExtensionHandlesForFilePath method resolves the owning extension for any file path by checking both exact matches and prefix matches against watched directories. Directories themselves are excluded from the paths passed to chokidar (since chokidar already watches the extension directory), but files inside them are still attributed to the correct extension.
  • In AppEventWatcher, after building extensions, the set of watched paths is compared before and after the build. If new paths were registered (e.g., a new asset directory was discovered), the file watcher is restarted to pick them up.

How to test your changes?

  1. Create an app-home extension that uses include_assets with a asset config key pointing to a directory.
  2. Run shopify app dev.
  3. Add a file inside the watched asset directory.
  4. Confirm that the change is detected and triggers the expected rebuild/update.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

Copy link
Copy Markdown
Contributor Author

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

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label May 5, 2026
@melissaluu melissaluu force-pushed the 05-05-add-directories-to-watched-files branch 4 times, most recently from 5f3d9d6 to 92ac699 Compare May 5, 2026 22:05
@melissaluu melissaluu changed the title add-directories-to-watched-files Watch asset directories for changes during dev May 5, 2026
@melissaluu melissaluu force-pushed the 05-05-add-directories-to-watched-files branch from 92ac699 to 4034f2f Compare May 5, 2026 22:11
@melissaluu melissaluu marked this pull request as ready for review May 5, 2026 22:11
Copilot AI review requested due to automatic review settings May 5, 2026 22:11
@melissaluu melissaluu requested a review from a team as a code owner May 5, 2026 22:11
@melissaluu melissaluu requested review from alfonso-noriega, isaacroldan and vividviolet and removed request for Copilot May 5, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant