Watch asset directories for changes during dev#7470
Open
melissaluu wants to merge 1 commit intomainfrom
Open
Conversation
5f3d9d6 to
92ac699
Compare
dev
92ac699 to
4034f2f
Compare
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?
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 duringdev. 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
ExtensionInstanceto track additional watched paths beyond its source imports, and wires it into the file watcher and build pipeline:addWatchedPath,getWatchedPaths, andclearWatchedPathsmethods toExtensionInstance. Paths are stored in a deduplicatedSetand are included in the output ofwatchedFiles().executeIncludeAssetsStep, directory-type asset sources are registered as watched paths on the extension after being copied, so the watcher knows to monitor them.FileWatcher, theextensionWatchedFilesmap now tracks both files and directories. A newgetExtensionHandlesForFilePathmethod 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.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?
app-homeextension that usesinclude_assetswith aassetconfig key pointing to a directory.shopify app dev.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add