Skip to content

Comments

fix: cachedTransformMiddleware for direct css requests#15919

Merged
patak-dev merged 2 commits intomainfrom
fix/cached-transform-middleware-for-direct-css-requests
Feb 15, 2024
Merged

fix: cachedTransformMiddleware for direct css requests#15919
patak-dev merged 2 commits intomainfrom
fix/cached-transform-middleware-for-direct-css-requests

Conversation

@patak-dev
Copy link
Member

Description

Fixes ttps://github.com/danielroe/css-flash-repro

The check we added in #15586 to detect mixed etags between direct and imported CSS was wrong. See explanation here to understand the problem: https://github.com/vitejs/vite/pull/15586/files#r1453060051. The issue is that isDirectRequest doesn't work because the query isn't added until the transform middleware kicks in.

This PR fixes the issue by reverting back to the previous 304 scheme for direct CSS requests. Imported CSS and all JS files will still go through the optimized path.

If we move from ?direct to marking with ?import as we do with assets, we may be able to optimize direct CSS imports too.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@bolt-new-by-stackblitz
Copy link

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

@patak-dev patak-dev added p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release feat: css feat: dev dev server labels Feb 15, 2024
@patak-dev
Copy link
Member Author

The backend-integration test that imports a CSS file and also linked it was failing if we only avoid the optimization for direct requests. So the PR now bails out of it for all CSS files.

@patak-dev patak-dev merged commit 5099028 into main Feb 15, 2024
@patak-dev patak-dev deleted the fix/cached-transform-middleware-for-direct-css-requests branch February 15, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: css feat: dev dev server p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants