From b99fa664f8f3c4db634379ed79e83657457e40e8 Mon Sep 17 00:00:00 2001 From: "shopify-build-cli[bot]" <145388831+shopify-build-cli[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 09:29:41 +0000 Subject: [PATCH] Update from World Published by the World mirror. World-Commit: 0e8a480ed871959edfb7fc3e3701d94bc62b4457 --- .changeset/windows-app-config-reload.md | 5 +++ .../dev/app-events/file-watcher.test.ts | 45 +++++++++++++++++++ .../services/dev/app-events/file-watcher.ts | 4 +- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 .changeset/windows-app-config-reload.md diff --git a/.changeset/windows-app-config-reload.md b/.changeset/windows-app-config-reload.md new file mode 100644 index 00000000000..d0b3facaa50 --- /dev/null +++ b/.changeset/windows-app-config-reload.md @@ -0,0 +1,5 @@ +--- +'@shopify/app': patch +--- + +Fix `app dev` on Windows not reloading the app when `shopify.app.toml` changes diff --git a/packages/app/src/cli/services/dev/app-events/file-watcher.test.ts b/packages/app/src/cli/services/dev/app-events/file-watcher.test.ts index 656f890f103..c78131bc6d2 100644 --- a/packages/app/src/cli/services/dev/app-events/file-watcher.test.ts +++ b/packages/app/src/cli/services/dev/app-events/file-watcher.test.ts @@ -374,6 +374,51 @@ describe('file-watcher events', () => { }, ) + test('a change to the app config reloads it when chokidar reports the path with backslashes, as on Windows', async () => { + await inTemporaryDirectory(async (dir) => { + // Given + const configPath = joinPath(dir, 'shopify.app.toml') + const app = testAppLinked({ + allExtensions: [], + directory: dir, + configPath, + configuration: { + ...DEFAULT_CONFIG, + extension_directories: ['extensions'], + } as any, + }) + + let eventHandler: any + const mockWatcher = { + on: vi.fn((event: string, listener: any) => { + if (event === 'all') { + eventHandler = listener + } + return mockWatcher + }), + close: vi.fn(() => Promise.resolve()), + } + vi.spyOn(chokidar, 'watch').mockReturnValue(mockWatcher as any) + + const fileWatcher = new FileWatcher(app, outputOptions, 50) + const emitted = new Promise((resolve) => { + fileWatcher.onChange((events) => { + if (events.length > 0) resolve(events) + }) + }) + await fileWatcher.start() + await flushPromises() + + // When + await eventHandler('change', configPath.replace(/\//g, '\\'), undefined) + + // Then + await expect(emitted).resolves.toEqual([ + expect.objectContaining({type: 'extensions_config_updated', extensionPath: dir}), + ]) + }) + }) + test.each(multiEventTestCases)( 'The event $name returns the expected WatcherEvent', async ({name, fileSystemEvents, expectedEvent}) => { diff --git a/packages/app/src/cli/services/dev/app-events/file-watcher.ts b/packages/app/src/cli/services/dev/app-events/file-watcher.ts index 177b7fdd1c5..cc253ea062e 100644 --- a/packages/app/src/cli/services/dev/app-events/file-watcher.ts +++ b/packages/app/src/cli/services/dev/app-events/file-watcher.ts @@ -290,7 +290,7 @@ export class FileWatcher { private readonly handleFileEvent = (event: string, path: string) => { const startTime = startHRTime() const normalizedPath = normalizePath(path) - const isConfigAppPath = path === this.app.configPath + const isConfigAppPath = normalizedPath === normalizePath(this.app.configPath) const isExtensionToml = path.endsWith('.extension.toml') outputDebug(`🌀: ${event} ${path.replace(this.app.directory, '')}\n`) @@ -370,7 +370,7 @@ export class FileWatcher { extensionHandle?: string, ) { const isExtensionToml = path.endsWith('.extension.toml') - const isConfigAppPath = path === this.app.configPath + const isConfigAppPath = normalizePath(path) === normalizePath(this.app.configPath) switch (event) { case 'change':