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

Fix new file detection in PostCSS plugin #14829

Merged
merged 11 commits into from
Oct 30, 2024
Merged

Conversation

thecrypticace
Copy link
Contributor

We broke this at some point — probably when we tried to optimize rebuilds in PostCSS by not performing a full auto-source detection scan.

This PR addresses this problem by:

  1. Storing a list of found directories
  2. Comparing their mod times on every scan
  3. If the mod time has changed we scan the directory for new files which we then store and scan

@thecrypticace thecrypticace requested a review from a team as a code owner October 30, 2024 13:22
@thecrypticace thecrypticace force-pushed the fix/v4-new-file-detection branch from 5e9a595 to 8bd9176 Compare October 30, 2024 13:24
@thecrypticace thecrypticace enabled auto-merge (squash) October 30, 2024 14:23
Copy link
Member

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

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

Few small changes, but I like it.

.filter_map(Result::ok)
}

#[tracing::instrument(skip(root))]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[tracing::instrument(skip(root))]
#[tracing::instrument(skip_all)]

read_dir(root, None)
}

#[tracing::instrument(skip(root))]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[tracing::instrument(skip(root))]
#[tracing::instrument(skip_all)]

.filter(|path| !known.contains(path))
.collect::<Vec<_>>();

modified_dirs.clear();
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit cursed, I love it.

@@ -27,9 +27,25 @@ static IGNORED_CONTENT_DIRS: sync::LazyLock<Vec<&'static str>> =

#[tracing::instrument(skip(root))]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[tracing::instrument(skip(root))]
#[tracing::instrument(skip_all)]

@thecrypticace thecrypticace merged commit 3b2ca85 into next Oct 30, 2024
1 check passed
@thecrypticace thecrypticace deleted the fix/v4-new-file-detection branch October 30, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants