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: add caching to PostCSS for regular stylesheets #6505

Merged
merged 22 commits into from
Jun 1, 2023

Conversation

markdalgleish
Copy link
Member

For now this is focused on regular stylesheets. Future PRs will extend this to more PostCSS touch points.

This PR introduces a generic file watch cache that can be used to cache async file processing and invalidate cache entries whenever relevant files are changed. I've integrated this into both old and new dev servers, and for consistency I've also integrated it into the build process so that plugins don't need to behave differently between dev and build and can always assume the presence of the cache.

Note that our watcher logic in watch.ts needed to be patched so that watch paths are always absolute. I've added a comment explaining why this is the case, but basically we need to always watch absolute paths so that Chokidar provides absolute paths in change events, which is important to ensure consistent values for the cache.

To test this, I've added some more complex PostCSS usage to our HMR test.

@changeset-bot
Copy link

changeset-bot bot commented May 29, 2023

🦋 Changeset detected

Latest commit: 8f8c3aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@remix-run/dev Major
create-remix Major
@remix-run/css-bundle Major
remix Major
@remix-run/architect Major
@remix-run/cloudflare Major
@remix-run/cloudflare-pages Major
@remix-run/cloudflare-workers Major
@remix-run/deno Major
@remix-run/eslint-config Major
@remix-run/express Major
@remix-run/netlify Major
@remix-run/node Major
@remix-run/react Major
@remix-run/serve Major
@remix-run/server-runtime Major
@remix-run/testing Major
@remix-run/vercel Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@markdalgleish markdalgleish marked this pull request as ready for review May 29, 2023 20:59
Copy link
Member

@jacob-ebey jacob-ebey left a comment

Choose a reason for hiding this comment

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

I like the cache abstraction, should serve us well.

@markdalgleish markdalgleish merged commit ce07e84 into dev Jun 1, 2023
@markdalgleish markdalgleish deleted the markdalgleish/postcss-cache branch June 1, 2023 23:06
@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2023

🤖 Hello there,

We just published version v0.0.0-nightly-70cc627-20230602 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2023

🤖 Hello there,

We just published version 1.17.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2023

🤖 Hello there,

We just published version 1.17.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants