archetype-themes / plugin-theme-component

A Shopify CLI plugin for building theme components.
MIT License
9 stars 4 forks source link

Run a file diff before installing a build file #348

Closed montalvomiguelo closed 7 months ago

montalvomiguelo commented 8 months ago

Fixes #340

This PR minimizes the number of file writes/copies by checking the diff between sources and destinations so that the Shopify CLI processes and syncs changes faster.

  1. It restores build directories and external repositories only during the initial build so subsequent builds can check file differences.
  2. It updates the current write and copy functions to check file differences before performing operations.
  3. It updates the importmap processor to consistently output entries in non-decreasing order.

I tested that this solution works as expected by starting dev mode with Archie and serving my theme via shopify theme dev --path .explorer --verbose

Before

Shopify CLI had to process all files for potential sync

Screenshot 2024-02-25 at 7 26 50 PM

After

Shopify CLI processes and syncs the files that have changed only

Screenshot 2024-02-25 at 7 26 02 PM
charlie-quinn commented 8 months ago

Whoa. 👏

bertiful commented 7 months ago

Thanks for this! Tested and it's definitely way more tolerable than it was before—great first step. I'm wondering if we can eventually speed it up even more as it still takes around 5 seconds from compilation to actually seeing the file change in preview.

Are we able to merge this in? cc @fleveillee

fleveillee commented 7 months ago

This was merged through https://github.com/archetype-themes/plugin-theme-component/pull/365