fix(analysis): warnings for dynamic imports that use static template literals#14458
fix(analysis): warnings for dynamic imports that use static template literals#14458bluwy merged 6 commits intovitejs:mainfrom
Conversation
|
|
1148b7d to
8509b58
Compare
| } else if (templateLiteralRE.test(rawUrl)) { | ||
| // Only static template literal will into this branch. | ||
| // It has variables will processed in importMetaGlob.ts | ||
| specifier = rawUrl.replace(templateLiteralRE, '$1') |
There was a problem hiding this comment.
I don't think this is correct.
Dynamic import with /* @vite-ignore */ or dynamic imports that cannot be handled with the dynamic-import plugin (e.g. import(`${startsWithVariable}/foo`)) will be still there.
https://stackblitz.com/edit/vitejs-vite-fnln8a?file=main.js&terminal=dev

So templateLiteralRE.test(rawUrl) will match `foo${va}`
https://stackblitz.com/edit/node-ptwy2i?file=index.js
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, I realize that. A dynamic import that doesn't conform to the rules will still get in here. So do I just need to exclude paths containing variables here?
There was a problem hiding this comment.
So do I just need to exclude paths containing variables here?
I think so 👍
sapphi-red
left a comment
There was a problem hiding this comment.
import(`foo\${bar}.js`) will still cause a warning but I guess that's fine.
…literals (#14458) Co-authored-by: 翠 / green <green@sapphi.red>
…literals (#14458) Co-authored-by: 翠 / green <green@sapphi.red>
Description
When I finished this PR, I noticed that there was another one #14103 being processed. But I think we shouldn't hide warnings.
Fixes: #14101
Closes: #14103
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).