Skip to content

Commit

Permalink
Merge pull request #4544 from montalvomiguelo/fix-hotreload-sections
Browse files Browse the repository at this point in the history
Fix hot reload on sections
  • Loading branch information
karreiro authored Oct 1, 2024
2 parents e0a977f + a2f31c2 commit cd9c393
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/smart-islands-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/theme': patch
---

Fix hot reload on sections
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('hot-reload server', () => {
const hotReloadEventsLengthBeforeChange = hotReloadEvents.length
// Since the JSON file was removed, the section file is not referenced anymore:
await triggerFileEvent('change', testSectionFileKey)
expect(hotReloadEvents).toHaveLength(hotReloadEventsLengthBeforeChange)
expect(hotReloadEvents.at(-1)).toMatch(`data: {"type":"full","key":"${testSectionFileKey}"}`)
await nextTick()

// -- Updates section groups:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ function hotReloadSections(key: string, ctx: DevServerContext) {

if (sectionsToUpdate.size > 0) {
emitHotReloadEvent({type: 'section', key, names: [...sectionsToUpdate]})
} else {
emitHotReloadEvent({type: 'full', key})
}
}

Expand Down

0 comments on commit cd9c393

Please sign in to comment.