fix(glob): css imports injecting a ?used query to export the css string#6949
fix(glob): css imports injecting a ?used query to export the css string#6949patak-cat merged 9 commits intovitejs:mainfrom
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.
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.
I seem to have found a pattern that when a fragment is reused it should be extracted. 😀
There was a problem hiding this comment.
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. |
Description
fix: #6938
Additional context
import 'xx.css' had inconsistency.
in importAnalysisBuild plugins differentiate CSS imports, and add
usedquery in the css import expression. glob / globEager feature also not default import but get emtry string.this PR add the
?usedin the glob / globEager importWhat is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).