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(glob): css imports injecting a ?used query to export the css string #6949
Conversation
packages/vite/src/node/importGlob.ts
Outdated
@@ -94,12 +95,17 @@ export async function transformImportGlob( | |||
)},` | |||
} else if (isEager) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the code is going to be more clear if we change it to
} else {
const importeeUrl = isCSSRequest(importee) ? `${importee}?used` : importee
if (isEager) {
...
}
else {
...
}
}
We can avoid repeating the condition, and the main else
makes it more evident that we are dealing with the non-raw case in both branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seem to have found a pattern that when a fragment is reused it should be extracted. 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha, not always, early abstraction is sometimes worse than duplicating code. But in this case, the variable applied to both branches when it was non-raw. I moved inside the else
case, as it is not used in the raw
branch.
thanks @patak-dev this is good change. |
oh, It was already suggested, but I didn't notice it. Thanks for showing me the good case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Description
fix: #6938
Additional context
import 'xx.css' had inconsistency.
in importAnalysisBuild plugins differentiate CSS imports, and add
used
query in the css import expression. glob / globEager feature also not default import but get emtry string.this PR add the
?used
in the glob / globEager importWhat is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).