Skip to content

Commit 93dc1f4

Browse files
committed
Bump @shopify/theme-hot-reload to 0.0.18
1 parent eaa8b7c commit 93dc1f4

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

packages/theme/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"yaml": "2.7.0"
5252
},
5353
"devDependencies": {
54-
"@shopify/theme-hot-reload": "^0.0.11",
54+
"@shopify/theme-hot-reload": "^0.0.18",
5555
"@vitest/coverage-istanbul": "^1.6.0",
5656
"node-stream-zip": "^1.15.0"
5757
},

packages/theme/src/cli/utilities/theme-environment/hot-reload/server.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('Hot Reload', () => {
9191

9292
const expectedSectionEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${testSectionFileKey}","payload":{"sectionNames":["first","second"],"replaceTemplates":${JSON.stringify(
9393
getInMemoryTemplates(ctx),
94-
)},"liquidTagsModified":{"stylesheet":false,"javascript":false}},"version":"${HOT_RELOAD_VERSION}"}`
94+
)},"updatedFileParts":{"stylesheetTag":false,"javascriptTag":false}},"version":"${HOT_RELOAD_VERSION}"}`
9595

9696
// Verify local sync event
9797
expect(hotReloadEvents.at(-1)).toMatch(expectedSectionEvent)
@@ -142,7 +142,7 @@ describe('Hot Reload', () => {
142142
// Since this is a template, sectionNames will be empty (no sections to reload)
143143
const expectedTemplateEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${templateKey}","payload":{"sectionNames":[],"replaceTemplates":${JSON.stringify(
144144
getInMemoryTemplates(ctx),
145-
)},"liquidTagsModified":{"stylesheet":false,"javascript":false}},"version":"${HOT_RELOAD_VERSION}"}`
145+
)},"updatedFileParts":{"stylesheetTag":false,"javascriptTag":false}},"version":"${HOT_RELOAD_VERSION}"}`
146146

147147
// Verify local sync event for JSON update
148148
expect(hotReloadEvents.at(-1)).toMatch(expectedTemplateEvent)
@@ -163,7 +163,7 @@ describe('Hot Reload', () => {
163163
// Since this is a section group, sectionNames will contain all the section names
164164
const expectedSectionGroupEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${sectionGroupKey}","payload":{"sectionNames":["first","second"],"replaceTemplates":${JSON.stringify(
165165
getInMemoryTemplates(ctx),
166-
)},"liquidTagsModified":{"stylesheet":false,"javascript":false}},"version":"${HOT_RELOAD_VERSION}"}`
166+
)},"updatedFileParts":{"stylesheetTag":false,"javascriptTag":false}},"version":"${HOT_RELOAD_VERSION}"}`
167167

168168
// Verify local sync event for JSON update
169169
expect(hotReloadEvents.at(-1)).toMatch(expectedSectionGroupEvent)
@@ -178,7 +178,7 @@ describe('Hot Reload', () => {
178178
expect(hotReloadEvents.at(-1)).toMatch(
179179
`data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${anotherSectionKey}","payload":{"sectionNames":["first","second"],"replaceTemplates":${JSON.stringify(
180180
getInMemoryTemplates(ctx),
181-
)},"liquidTagsModified":{"stylesheet":false,"javascript":false}},"version":"${HOT_RELOAD_VERSION}"}`,
181+
)},"updatedFileParts":{"stylesheetTag":false,"javascriptTag":false}},"version":"${HOT_RELOAD_VERSION}"}`,
182182
)
183183
// Wait for remote sync
184184
await nextTick()
@@ -197,7 +197,7 @@ describe('Hot Reload', () => {
197197
expect(getInMemoryTemplates(ctx)).toEqual({[anotherSectionKey]: 'default-value'})
198198
const expectedUnreferencedSectionEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${anotherSectionKey}","payload":{"sectionNames":[],"replaceTemplates":${JSON.stringify(
199199
getInMemoryTemplates(ctx),
200-
)},"liquidTagsModified":{"stylesheet":false,"javascript":false}},"version":"${HOT_RELOAD_VERSION}"}`
200+
)},"updatedFileParts":{"stylesheetTag":false,"javascriptTag":false}},"version":"${HOT_RELOAD_VERSION}"}`
201201
expect(hotReloadEvents.at(-1)).toMatch(expectedUnreferencedSectionEvent)
202202
await nextTick()
203203
expect(hotReloadEvents.at(-1)).toMatch(expectedUnreferencedSectionEvent.replace('local', 'remote'))
@@ -207,7 +207,7 @@ describe('Hot Reload', () => {
207207
await triggerFileEvent('add', cssFileKey)
208208
// It does not add assets to the in-memory templates:
209209
expect(getInMemoryTemplates(ctx)).toEqual({})
210-
const expectedCssEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${cssFileKey}","payload":{"sectionNames":[],"replaceTemplates":{},"liquidTagsModified":{"stylesheet":false,"javascript":false}},"version":"${HOT_RELOAD_VERSION}"}`
210+
const expectedCssEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${cssFileKey}","payload":{"sectionNames":[],"replaceTemplates":{},"updatedFileParts":{"stylesheetTag":false,"javascriptTag":false}},"version":"${HOT_RELOAD_VERSION}"}`
211211
expect(hotReloadEvents.at(-1)).toMatch(expectedCssEvent)
212212
// Wait for remote sync
213213
await nextTick()
@@ -218,7 +218,7 @@ describe('Hot Reload', () => {
218218
await triggerFileEvent('add', cssLiquidFileKey)
219219
// It does not add assets to the in-memory templates:
220220
expect(getInMemoryTemplates(ctx)).toEqual({})
221-
const expectedCssLiquidEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${cssLiquidFileKey}","payload":{"sectionNames":[],"replaceTemplates":{},"liquidTagsModified":{"stylesheet":false,"javascript":false}},"version":"${HOT_RELOAD_VERSION}"}`
221+
const expectedCssLiquidEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${cssLiquidFileKey}","payload":{"sectionNames":[],"replaceTemplates":{},"updatedFileParts":{"stylesheetTag":false,"javascriptTag":false}},"version":"${HOT_RELOAD_VERSION}"}`
222222
expect(hotReloadEvents.at(-1)).toMatch(expectedCssLiquidEvent)
223223
// Wait for remote sync
224224
await nextTick()
@@ -227,7 +227,7 @@ describe('Hot Reload', () => {
227227
// -- Test other file types (e.g. JS) --
228228
const jsFileKey = 'assets/something.js'
229229
await triggerFileEvent('add', jsFileKey)
230-
const expectedJsEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${jsFileKey}","payload":{"sectionNames":[],"replaceTemplates":{},"liquidTagsModified":{"stylesheet":false,"javascript":false}},"version":"${HOT_RELOAD_VERSION}"}`
230+
const expectedJsEvent = `data: {"sync":"local","themeId":"${THEME_ID}","type":"update","key":"${jsFileKey}","payload":{"sectionNames":[],"replaceTemplates":{},"updatedFileParts":{"stylesheetTag":false,"javascriptTag":false}},"version":"${HOT_RELOAD_VERSION}"}`
231231
expect(hotReloadEvents.at(-1)).toMatch(expectedJsEvent)
232232
// Wait for remote sync
233233
await nextTick()

packages/theme/src/cli/utilities/theme-environment/hot-reload/server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ function collectReloadInfoForFile(key: string, ctx: DevServerContext) {
362362
return {
363363
sectionNames: type === 'sections' ? findSectionNamesToReload(key, ctx) : [],
364364
replaceTemplates: needsTemplateUpdate(key) ? getInMemoryTemplates(ctx) : {},
365-
liquidTagsModified: getLiquidTagsModified(key, ctx),
365+
updatedFileParts: getUpdatedFileParts(key, ctx),
366366
}
367367
}
368368

@@ -404,20 +404,20 @@ function isAsset(key: string) {
404404
return key.startsWith('assets/')
405405
}
406406

407-
function getLiquidTagsModified(key: string, ctx: DevServerContext): {stylesheet: boolean; javascript: boolean} {
407+
function getUpdatedFileParts(key: string, ctx: DevServerContext): {stylesheetTag: boolean; javascriptTag: boolean} {
408408
const file = ctx.localThemeFileSystem.files.get(key)
409409
const validPrefixes = ['sections/', 'snippets/', 'blocks/']
410410
const isValidFileType = validPrefixes.some((prefix) => key.startsWith(prefix)) && key.endsWith('.liquid')
411411

412412
if (!file || !isValidFileType) {
413-
return {stylesheet: false, javascript: false}
413+
return {stylesheetTag: false, javascriptTag: false}
414414
}
415415

416416
const tagContents = getTagContents(file)
417417

418418
return {
419-
stylesheet: tagContents.stylesheet.changed,
420-
javascript: tagContents.javascript.changed,
419+
stylesheetTag: tagContents.stylesheet.changed,
420+
javascriptTag: tagContents.javascript.changed,
421421
}
422422
}
423423

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)