diff --git a/packages/theme/src/cli/utilities/theme-fs.ts b/packages/theme/src/cli/utilities/theme-fs.ts index abfd7a3612..67d8bbb80e 100644 --- a/packages/theme/src/cli/utilities/theme-fs.ts +++ b/packages/theme/src/cli/utilities/theme-fs.ts @@ -2,6 +2,7 @@ import {calculateChecksum} from './asset-checksum.js' import {applyIgnoreFilters, getPatternsFromShopifyIgnore} from './asset-ignore.js' import {Notifier} from './notifier.js' import {createSyncingCatchError} from './errors.js' +import {emitHotReloadEvent} from './theme-environment/hot-reload/server.js' import {DEFAULT_IGNORE_PATTERNS, timestampDateFormat} from '../constants.js' import {glob, readFile, ReadOptions, fileExists, mkdir, writeFile, removeFile} from '@shopify/cli-kit/node/fs' import {joinPath, basename, relativePath} from '@shopify/cli-kit/node/path' @@ -149,10 +150,14 @@ export function mountThemeFileSystem(root: string, options?: ThemeFileSystemOpti const [result] = await bulkUploadThemeAssets(Number(themeId), [{key: fileKey, value: content}], adminSession) if (result?.success) { - uploadErrors.delete(fileKey) + if (uploadErrors.has(fileKey)) { + uploadErrors.delete(fileKey) + emitHotReloadEvent({type: 'full', key: fileKey}) + } } else { const errors = result?.errors?.asset ?? ['Response was not successful.'] uploadErrors.set(fileKey, errors) + emitHotReloadEvent({type: 'full', key: fileKey}) throw new Error(errors.length === 1 ? errors[0] : errors.join('\n')) } diff --git a/packages/theme/src/cli/utilities/theme-uploader.ts b/packages/theme/src/cli/utilities/theme-uploader.ts index c9c48a8a49..c21979fd03 100644 --- a/packages/theme/src/cli/utilities/theme-uploader.ts +++ b/packages/theme/src/cli/utilities/theme-uploader.ts @@ -2,6 +2,7 @@ import {partitionThemeFiles} from './theme-fs.js' import {rejectGeneratedStaticAssets} from './asset-checksum.js' import {renderTasksToStdErr} from './theme-ui.js' import {createSyncingCatchError, renderThrownError} from './errors.js' +import {emitHotReloadEvent} from './theme-environment/hot-reload/server.js' import {AdminSession} from '@shopify/cli-kit/node/session' import {Result, Checksum, Theme, ThemeFileSystem} from '@shopify/cli-kit/node/themes/types' import {AssetParams, bulkUploadThemeAssets, deleteThemeAsset} from '@shopify/cli-kit/node/themes/api' @@ -380,6 +381,7 @@ export function updateUploadErrors(result: Result, localThemeFileSystem: ThemeFi } else { const errors = result.errors?.asset ?? ['Response was not successful.'] localThemeFileSystem.uploadErrors.set(result.key, errors) + emitHotReloadEvent({type: 'full', key: result.key}) } }