-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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: dont resolve imports with malformed URI #16244
fix: dont resolve imports with malformed URI #16244
Conversation
Run & review this pull request in StackBlitz Codeflow. |
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.
vite/playground/assets/index.html
Lines 535 to 552 in 6c8c7b8
function testDynamicImportMetaUrlWithQuery(name, i) { | |
// prettier-ignore | |
const metaUrl = new URL(`./nested/${name}.png?abc`, import.meta.url,) | |
text(`.dynamic-import-meta-url-${i}-query`, metaUrl) | |
document.querySelector(`.dynamic-import-meta-url-img-${i}-query`).src = | |
metaUrl | |
} | |
testDynamicImportMetaUrlWithQuery('icon', 1) | |
testDynamicImportMetaUrlWithQuery('asset', 2) | |
function testDynamicImportMetaUrlWithTernaryOperator(name, i) { | |
// prettier-ignore | |
const metaUrl = new URL(`./nested/${1 === 0 ? 'failed' : name}.png?abc`, import.meta.url,) | |
text(`.dynamic-import-meta-url-${i}-ternary`, metaUrl) | |
document.querySelector(`.dynamic-import-meta-url-img-${i}-ternary`).src = | |
metaUrl | |
} |
These
new URL
s is transformed to import.meta.glob
and then it is transformed to import url from './nested/テスト-測試-white space%.png'
. These should be import url from './nested/テスト-測試-white space%25.png'
, but that change opens up a can of worms (#16243), so I simply renamed back these files and put a different file in a different directory.
/ecosystem-ci run |
📝 Ran ecosystem CI on ✅ analogjs, astro, histoire, ladle, laravel, marko, nuxt, previewjs, quasar, qwik, rakkas, remix, sveltekit, unocss, vike, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-pages, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress, vitest |
hey i know this was meant to fix #15298 but the issue still persists in vite 6. |
@hichemfantar I reopened #15298 👍 |
Description
To align with native ESM, Vite should not resolve
import './foo%.js'
to./foo%.js
(#15298 (comment)).repro with node: https://stackblitz.com/edit/node-ccxwu6?file=index.js
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).