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

dev server: handle hmr and css importer persistence #7389

Merged
merged 3 commits into from
Mar 4, 2025
Merged

Conversation

thejackshelton
Copy link
Member

@thejackshelton thejackshelton commented Mar 2, 2025

On HMR reload (still initial render), css imports are losing their persistence. Currently top level css imports think they are not top level after an hmr refresh, this set keeps track of that.

What is it?

  • Bug

Description

Checklist

  • My code follows the developer guidelines of this project
  • I performed a self-review of my own code
  • I added a changeset with pnpm change
  • I made corresponding changes to the Qwik docs
  • I added new tests to cover the fix / functionality

@thejackshelton thejackshelton requested a review from a team as a code owner March 2, 2025 19:15
Copy link

changeset-bot bot commented Mar 2, 2025

🦋 Changeset detected

Latest commit: 6ea203c

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

This PR includes changesets to release 4 packages
Name Type
@builder.io/qwik Patch
eslint-plugin-qwik Patch
@builder.io/qwik-city Patch
create-qwik Patch

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

@thejackshelton thejackshelton changed the title handle hmr and css importer persistence dev server: handle hmr and css importer persistence Mar 2, 2025
Copy link

pkg-pr-new bot commented Mar 2, 2025

Open in Stackblitz

npm i https://pkg.pr.new/@builder.io/qwik@7389
npm i https://pkg.pr.new/@builder.io/qwik-city@7389
npm i https://pkg.pr.new/eslint-plugin-qwik@7389
npm i https://pkg.pr.new/create-qwik@7389

commit: 0c90802

Copy link
Contributor

github-actions bot commented Mar 2, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 0c90802

@Varixo Varixo requested a review from Copilot March 2, 2025 21:33

Choose a reason for hiding this comment

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

PR Overview

This PR fixes a bug where CSS imports lose their persistence after an HMR reload by tracking CSS importers more accurately.

  • Updated the changeset to indicate a patch release.
  • Introduced a new Set to track CSS importers post-HMR reload.
  • Modified the injection logic by ensuring CSS files imported by CSS are not redundantly re-injected.

Reviewed Changes

File Description
.changeset/quiet-flowers-divide.md Updates changeset with release note for the patch.
packages/qwik/src/optimizer/src/plugins/vite-dev-server.ts Adds logic to track and check CSS importers to maintain HMR persistence.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

packages/qwik/src/optimizer/src/plugins/vite-dev-server.ts:90

  • [nitpick] The variable name 'cssImportedByCSS' is somewhat ambiguous. Consider renaming it to a more descriptive name such as 'persistentCssImports' to clearly convey its purpose.
const cssImportedByCSS = new Set<string>();
Copy link
Member

@Varixo Varixo left a comment

Choose a reason for hiding this comment

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

Lgtm

Copy link
Member

@wmertens wmertens left a comment

Choose a reason for hiding this comment

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

LGTM

@wmertens wmertens merged commit 68b2bd9 into main Mar 4, 2025
21 checks passed
@wmertens wmertens deleted the dev-server-fixes branch March 4, 2025 07:27
@github-actions github-actions bot mentioned this pull request Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants