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

Inconsistent order of styles when cssCodeSplit is false #11662

Closed
7 tasks done
lsdsjy opened this issue Jan 11, 2023 · 0 comments · Fixed by #11671
Closed
7 tasks done

Inconsistent order of styles when cssCodeSplit is false #11662

lsdsjy opened this issue Jan 11, 2023 · 0 comments · Fixed by #11671
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@lsdsjy
Copy link
Contributor

lsdsjy commented Jan 11, 2023

Describe the bug

Problem

I expect that there should not be any different behaviours whether cssCodeSplit is on. However, as shown in the reproduction link, I get diffenrent results with different status of cssCodeSplit:

cssCodeSplit: true

image

cssCodeSplit: false

image

See the reproduction for more information.

Analysis

This problem is basically an outcome of #9949, which tweaks the order of collecting deps such that styles of the importer override those of the imported chunks. But the order in the situation of cssCodeSplit set to false is still "parent-first", which is the same as the order of calling renderChunk, i.e. we collect the importer's styles first, then the imported chunks and so on.

For example, in the reproduction provided below, the style of Button is collected before the GreenButton if cssCodeSplit is true which is the opposite of what happens if cssCodeSplit is false.

A possible fix is #11671

Reproduction

https://stackblitz.com/edit/vite-mlkxv1?file=main.jsx

Steps to reproduce

  1. Open the stackblitz container
  2. Run yarn serve-split, a green button and a blue button will show in the preview window
  3. Control-C and run yarn serve will get a black button and a blue button

System Info

Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @vitejs/plugin-react: ^1.1.1 => 1.3.2 
    vite: ^4.0.4 => 4.0.4

Used Package Manager

npm

Logs

No response

Validations

lsdsjy added a commit to lsdsjy/vite that referenced this issue Jan 12, 2023
@sapphi-red sapphi-red added feat: css p3-minor-bug An edge case that only affects very specific usage (priority) labels Jul 24, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants