fix(build-import-analysis): should not append ?used when css request has ?url or ?raw#11910
fix(build-import-analysis): should not append ?used when css request has ?url or ?raw#11910bluwy merged 2 commits intovitejs:mainfrom
Conversation
|
Can you help review this PR @sapphi-red @bluwy Thanks. |
|
I think adding |
…has ?url or ?raw (fix vitejs#11893)
9759fc2 to
bdf93fd
Compare
done |
| (source.slice(expStart, start).includes('from') || isDynamicImport) && | ||
| // already has ?used query (by import.meta.glob) | ||
| !specifier.match(/\?used(&|$)/) && | ||
| !specifier.match(/\?(used|raw|url)(&|$)/) && |
There was a problem hiding this comment.
I think we can use SPECIAL_QUERY_RE to check the special queries, and leave !specifier.match(/\?used(&|$)/) as is.
PS: I also tried to implement the idea I mentioned in discord last week. It's tricky since dynamic imports of css makes it harder to process it, which reminds me that I think we haven't logged the warnings for dynamic imports of CSS yet.
There was a problem hiding this comment.
We have some warnings at
vite/packages/vite/src/node/plugins/importAnalysis.ts
Lines 527 to 531 in a1019f8
vite/packages/vite/src/node/plugins/importMetaGlob.ts
Lines 330 to 334 in a1019f8
?used hack. I don't think it's related to this PR now though, and we can go in with this quick fix for now.
There was a problem hiding this comment.
Alright. Done with SPECIAL_QUERY_RE
Speaking of dynamic import CSS, is there an alternative?
There was a problem hiding this comment.
Speaking of dynamic import CSS, is there an alternative?
import('./foo.css').then(mod => mod.default) should now be replaced with import('./foo.css?inline').then(mod => mod.default). Dynamic import without using default import (import('./foo.css')) is fine.
Description
fix #11893
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).