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(css): track dependencies from addWatchFile for HMR #15608

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jan 15, 2024

Description

This PR moves the module-graph/HMR handling code in the cssPlugin, to a new cssAnalysisPlugin, which is placed at the end like import analysis. This way this.addWatchFile calls from plugins that transform the CSS will work and update appropriately.

This is helpful for SFC files like Vue/Svelte/Astro where the file is internally transformed into JS that imports the scoped CSS virtual module. And since they already pre-processed the CSS with dependencies, they can assign those dependencies to the CSS virtual modules directly. Today, the only workaround is to add the dependencies to the SFC file, which isn't accurate.

Additional context

Working on improving Astro's CSS HMR: withastro/astro#9370 😬


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added feat: css feat: hmr p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) labels Jan 15, 2024
Copy link

stackblitz bot commented Jan 15, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

Sounds good to me, and it makes things easier to follow to, nice one!

@patak-dev
Copy link
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on 9d0c7e0: Open

suite result latest scheduled
analogjs success success
astro success success
histoire failure failure
ladle success success
laravel failure failure
marko success success
nuxt success success
nx success success
previewjs success success
qwik failure success
rakkas success success
sveltekit success success
unocss failure failure
vike failure failure
vite-plugin-pwa success success
vite-plugin-react success success
vite-plugin-react-pages success success
vite-plugin-react-swc success success
vite-plugin-svelte success success
vite-plugin-vue success success
vite-setup-catalogue success success
vitepress failure failure
vitest success failure

@patak-dev
Copy link
Member

The qwik issue seems unrelated. I'll leave the PR unmerged until tomorrow in case someone else want to check it out.

@patak-dev patak-dev merged commit dfcb83d into main Jan 16, 2024
@patak-dev patak-dev deleted the fix-css-add-watch-file branch January 16, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: css feat: hmr p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants