Skip to content

fix: wire --poll flag through to chokidar in theme dev#7024

Draft
graygilmore wants to merge 1 commit intomainfrom
graygilmore/wire-poll-flag
Draft

fix: wire --poll flag through to chokidar in theme dev#7024
graygilmore wants to merge 1 commit intomainfrom
graygilmore/wire-poll-flag

Conversation

@graygilmore
Copy link
Contributor

Summary

  • The --poll flag was defined on theme dev but never wired through to chokidar's usePolling option, making it a no-op
  • On Linux/Windows, chokidar's fs.watch backend compares mtimeMs and suppresses change events when the timestamp hasn't changed. Build tools (like Gulp + Sass) that preserve the original source file's timestamp on compiled output cause file change events to be silently dropped
  • This wires poll through the full chain: command → service → mountThemeFileSystemchokidar.watch. When --poll is set, both usePolling: true and useFsEvents: false are passed to chokidar (useFsEvents: false is required because on macOS chokidar prefers FSEvents over polling even when usePolling: true is set)
  • Also unhides the --poll flag and improves its description to tell users when to use it

Related: https://community.shopify.dev/t/theme-dev-sometimes-misses-file-updates/29269/4

Test plan

  • New tests verify usePolling: true + useFsEvents: false are passed to chokidar when poll: true
  • New tests verify usePolling and useFsEvents are absent from chokidar options when poll is not set
  • All 44 existing tests in theme-fs.test.ts continue to pass
  • Manual: shopify theme dev --poll enables chokidar polling mode
  • Manual: shopify theme dev --help shows the --poll flag with improved description

🤖 Generated with Claude Code

The --poll flag was defined on the dev command but never passed to chokidar's usePolling option. On Linux/Windows, chokidar's fs.watch backend compares mtimeMs and suppresses change events when mtime hasn't changed. Build tools (like Gulp + Sass) that preserve the original source file's timestamp on compiled output cause chokidar to silently drop these events.

This wires poll through the full chain: command -> service -> mountThemeFileSystem -> chokidar.watch. When --poll is set, both usePolling: true and useFsEvents: false are passed to chokidar. useFsEvents: false is required because on macOS chokidar prefers FSEvents over polling even when usePolling is true.

Also unhides the --poll flag and improves its description to tell users when they'd want it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/themes/types.d.ts
@@ -30,6 +30,7 @@ export interface ThemeFileSystemOptions {
     listing?: string;
     noDelete?: boolean;
     notify?: string;
+    poll?: boolean;
 }
 /**
  * Represents a theme on the file system.

@github-actions
Copy link
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 77.31% 14586/18868
🟡 Branches 70.9% 7238/10209
🟡 Functions 76.3% 3706/4857
🟡 Lines 78.8% 13790/17501

Test suite run success

3813 tests passing in 1473 suites.

Report generated by 🧪jest coverage report action from d4fdcb5

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