Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Themes] Refactor CLI server events for Hot Reload (PoC Hot Reload for OSE) #4908

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ed57291
Adapt hot reloading for OSE
frandiox Nov 22, 2024
4f8f407
Wait full sync before doing full-reload
frandiox Nov 22, 2024
9dbd2ae
Move CORS logic
frandiox Nov 28, 2024
23cb3e1
Rely on section rendering API from the browser instead of cloud syncing
frandiox Nov 28, 2024
dbd0bb9
Show HR port in OSE url
frandiox Dec 9, 2024
4391c33
Introduce HR filters to fork logic for OSE without affecting CLI
frandiox Dec 9, 2024
1bd2a3e
Fix type in app ext
frandiox Dec 9, 2024
66ee3ec
Move hot reload decisions to frontend to increase client flexibility
frandiox Jan 6, 2025
0e1da8e
Basic support for OSE preview hot reload
frandiox Jan 7, 2025
ed65e1e
Support hot reload in prod Theme Preview
frandiox Jan 7, 2025
27b1102
Sections hot reload for OSE
frandiox Jan 8, 2025
8f661ed
Temporary fix for hot reloading sections in OSE
frandiox Jan 8, 2025
f9da2b2
Support hot reloading theme settings in OSE
frandiox Jan 8, 2025
8cf4d5e
Support hot reload for language files in OSE
frandiox Jan 9, 2025
5bf61d3
Skip SSE reconnection if it fails the first time to avoid console err…
frandiox Jan 9, 2025
dd4a80c
Support hot reload from Online Code Editor via OSE
frandiox Jan 9, 2025
62f53ad
Rename type and add support for create events
frandiox Jan 10, 2025
b54a3e2
Send all events to OSE
frandiox Jan 10, 2025
4fa7d47
Fix sections reload in OSE
frandiox Jan 10, 2025
01777c2
Remove comment
frandiox Jan 10, 2025
0c2b77d
Disable outdated test
frandiox Jan 10, 2025
f606b06
Simplify hot reload endpoints
frandiox Jan 21, 2025
45bb31f
Add mechanism to log to console from HMR logic
frandiox Jan 22, 2025
3319aaa
Use external dep for hot reloading client
frandiox Jan 22, 2025
15056ca
Use local theme-hot-reload script when indicated via env vars
frandiox Jan 22, 2025
666ef82
Rename isAppExtension to isThemeExtension
frandiox Jan 22, 2025
761d551
Restore links after bad merge
frandiox Jan 23, 2025
0579cf9
Fix types after rebase
frandiox Jan 23, 2025
37bc181
Get sectionKey from frontend
frandiox Jan 24, 2025
e15251d
Update server tests
frandiox Jan 24, 2025
b606592
Bump theme-hot-reload
frandiox Jan 24, 2025
8657282
Rename log param
frandiox Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/cli-kit/src/public/node/themes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ export type Key = string

export type ThemeFSEventName = 'add' | 'change' | 'unlink'

type OnSync = (onSuccess: () => void, onError?: () => void) => void

type ThemeFSEvent =
| {
type: 'unlink'
payload: {fileKey: Key; onSync?: (fn: () => void) => void}
payload: {fileKey: Key; onSync: OnSync}
}
| {
type: 'add' | 'change'
payload: {
fileKey: Key
onContent: (fn: (content: string) => void) => void
onSync: (fn: () => void) => void
onSync: OnSync
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"yaml": "2.7.0"
},
"devDependencies": {
"@shopify/theme-hot-reload": "^0.0.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should version the events here somehow? (in runtime)

This way, if we need to change something, we can prevent older versions of the CLI from breaking (we will likely need to keep triggering old events if we really change the shape of them)

"@vitest/coverage-istanbul": "^1.6.0",
"node-stream-zip": "^1.15.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/src/cli/services/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('dev', () => {
const urls = {
local: `http://${host}:${port}`,
giftCard: `http://${host}:${port}/gift_cards/[store_id]/preview`,
themeEditor: `https://${store}/admin/themes/${themeId}/editor`,
themeEditor: `https://${store}/admin/themes/${themeId}/editor?hr=${port}`,
preview: `https://${store}/?preview_theme_id=${themeId}`,
}

Expand Down Expand Up @@ -153,7 +153,7 @@ describe('dev', () => {
{
link: {
label: `Customize your theme at the theme editor (e)`,
url: `https://${store}/admin/themes/${themeId}/editor`,
url: `https://${store}/admin/themes/${themeId}/editor?hr=9292`,
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/cli/services/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function dev(options: DevOptions) {
const urls = {
local: `http://${host}:${port}`,
giftCard: `http://${host}:${port}/gift_cards/[store_id]/preview`,
themeEditor: `https://${options.store}/admin/themes/${options.theme.id}/editor`,
themeEditor: `https://${options.store}/admin/themes/${options.theme.id}/editor?hr=${port}`,
preview: `https://${options.store}/?preview_theme_id=${options.theme.id}`,
}

Expand Down

This file was deleted.

Loading
Loading