-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Refactors live reload to include more states and fix a few bugs with hot module reloading (HMR). ### Custom Dev Server A custom dev server was used to fix HMR due to a bug with Remix v2. A current issue exists regarding the issue with HMR here: remix-run/remix#7466. A current workaround to the issue is to use a custom dev server as described [in this comment](remix-run/remix#7466 (comment)). The sever implementation is based on a [community example for using ES Modules + TypeScript](https://github.com/xHomu/remix-v2-server/tree/esm-server.ts). ## Demos ### Added file ![image](https://github.com/chanzuckerberg/cryoet-data-portal/assets/2176050/699d41de-9be1-471f-a0f7-d913c7b8e279) ### Deleted file ![image](https://github.com/chanzuckerberg/cryoet-data-portal/assets/2176050/99f74017-cb04-4681-8b90-4dbd673063e3) ### Modified file Unlike when a file is added or deleted, the overlay for modified files only disappear when an HMR event is received from the server. That's why when the overlay disappears, the UI is immediately updated. If we did it when the bundle was finished building, there would be a small delay between the UI being rebuilt and being rerendered. https://github.com/chanzuckerberg/cryoet-data-portal/assets/2176050/c2d81d16-ef41-4c36-a82a-f69aec471d71 ### Multiple files Editing multiple files during an in progress live reload will prolong the reload, so it'd be nice to know which files were updated during the reload on the overlay screen. https://github.com/chanzuckerberg/cryoet-data-portal/assets/2176050/b85c410e-7c55-449b-92e6-eb3809a23187 ### Live reload taking long Sometimes live reload will appear stuck due to an error that is only visible within the terminal. Because of this, an additional warning is shown when live reload takes a long time to complete. <img width="1728" alt="image" src="https://github.com/chanzuckerberg/cryoet-data-portal/assets/2176050/94277c44-1087-49ba-ab3f-3c7470450226"> ### Websocket closed When the dev server is closed, the frontend will lose it's connection to the dev server's websocket connection. We show an overlay when this happens to make it clear that the dev server isn't running. <img width="1728" alt="image" src="https://github.com/chanzuckerberg/cryoet-data-portal/assets/2176050/28261614-331f-4d5b-8c82-2024a006ed18">
- Loading branch information
1 parent
d57d594
commit 4b07272
Showing
8 changed files
with
915 additions
and
539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 43 additions & 9 deletions
52
frontend/packages/data-portal/app/components/LiveReload/event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
/** | ||
* Enum for different events in the live reload websocket. | ||
*/ | ||
export enum LiveReloadEvent { | ||
Closed = 'live-reload-closed', | ||
Completed = 'live-reload-completed', | ||
Connected = 'live-reload-connected', | ||
Error = 'live-reload-error', | ||
Started = 'live-reload-started', | ||
export const LIVE_RELOAD_EVENT = 'live-reload-event' | ||
|
||
export enum LiveReloadEventType { | ||
Closed = 'closed', | ||
Completed = 'completed', | ||
Connected = 'connected', | ||
Error = 'error', | ||
Started = 'started', | ||
} | ||
|
||
interface LiveReloadClosedEvent { | ||
type: LiveReloadEventType.Closed | ||
code: string | ||
message?: string | ||
} | ||
|
||
interface LiveReloadCompletedEvent { | ||
type: LiveReloadEventType.Completed | ||
} | ||
|
||
interface LiveReloadConnectedEvent { | ||
type: LiveReloadEventType.Connected | ||
} | ||
|
||
interface LiveReloadErrorEvent { | ||
type: LiveReloadEventType.Error | ||
message: string | ||
error: string | ||
} | ||
|
||
interface LiveReloadStartedEvent { | ||
type: LiveReloadEventType.Started | ||
action: 'created' | 'changed' | 'deleted' | ||
file: string | ||
} | ||
|
||
export type LiveReloadStartedEventData = Omit<LiveReloadStartedEvent, 'type'> | ||
|
||
export type LiveReloadEvent = | ||
| LiveReloadClosedEvent | ||
| LiveReloadCompletedEvent | ||
| LiveReloadConnectedEvent | ||
| LiveReloadErrorEvent | ||
| LiveReloadStartedEvent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.