Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Fix hot reload when users update many files "simultaneously" #1830

Merged
merged 2 commits into from
Dec 9, 2021

Conversation

karreiro
Copy link
Contributor

@karreiro karreiro commented Dec 7, 2021

WHY are these changes introduced?

Some users rely on tools over their theme (like Webpack) to update multiple files in a very short period of time.

The message.date.modified list may contain multiple files in that kind of scenario. However, if the first file of the list doesn't require refreshing the entire page, while the second file does, the changes from the second file are not covered by the hot reload mechanism.

WHAT is this pull request doing?

This pull request introduces changes in the hot-reload.js module to analyze all modified files instead of considering only the first one (inspired by #1458).

How to test your changes?

Download the reproducer_remove_me.rb here.

# Initialize a new theme
$ shopify-dev theme init my_theme

# `theme serve` it
$ cd my_theme
$ pwd
/Users/karreiro/theme # ← Keep this path in mind
$ shopify-dev theme serve

# Open a a different terminal window
# Use the path above as a parameter for the `reproducer_remove_me.rb` reproducer
$ ruby reproducer_remove_me.rb /Users/karreiro/theme/my_theme

Before this PR:
Kapture 2021-12-07 at 14 52 27

After this PR:
Kapture 2021-12-07 at 14 43 55

Post-release steps

None.

Update checklist

  • I've added a CHANGELOG entry for this PR (if the change is public-facing)
  • I've considered possible cross-platform impacts (Mac, Linux, Windows).
  • I've left the version number as is (we'll handle incrementing this when releasing).
  • I've included any post-release steps in the section above.

@karreiro karreiro requested review from macournoyer, a team, hannachen and jesalerno84 and removed request for a team December 7, 2021 16:01
@karreiro karreiro changed the title Fix hot reload when many files users update many files "simultaneously" Fix hot reload when users update many files "simultaneously" Dec 7, 2021
Copy link
Contributor

@macournoyer macournoyer left a comment

Choose a reason for hiding this comment

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

🤩

@karreiro karreiro merged commit 95c2af0 into main Dec 9, 2021
@karreiro karreiro deleted the fix-1409-1 branch December 9, 2021 08:37
@hannachen hannachen mentioned this pull request Dec 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants