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
Import paths with query parameters containing ../
cause path normalization to fail
#13957
Comments
Start a new pull request in StackBlitz Codeflow. |
I don't recall frameworks using a query param with a relative path before. For a while, we were (somewhat) supporting Touching Could you tell us more about the use case though? Using relative paths after the |
(@kazupon should be able to explain the use case better than I do as he implemented it.) Due to a new Nuxt feature (layers) these paths can be multiple levels up from the running project, which causes these parameters to break the path during normalization. I'm not familiar enough yet with the way plugins for Vite work yet myself and ran into this trying to debug our issue, but I will look into your suggestion of keeping a paths map with IDs!
I noticed it being used a lot and I wouldn't want to introduce breaking changes but are there scenarios in which it is expected or preferred for |
|
@BobbieGoede I will add for your reference in the following, so background on using relative paths for queries in The background is influenced by the locale messages used by nuxt i18n and the architecture of vue-i18n's handling of them used internally by nuxt i18n. Key-value case: {
“hello”: “hello world!”
} hierarchical structure case: export default {
nest: {
bar: {
buz: “…"
}
}
} The nuxt i18n module supports the formats export default defineI18nLocale((locale) => {
// for example, fetch locale messages from nuxt server
return $fetch(`/api/${locale}`)
}) A bundler like vite can simply import a file with these locale messages and process it. For nuxt i18n, however, these locale messages must be precompiled into JavaScript in order to be processed. You can see here for the reason for precompiling. For static resources such as After some development of nuxt i18n module, the vue-i18n compiler used inside nuxt i18n can now compile locale messages with JIT style. I need to try nuxt i18n module refactoring to see if it needs virutal module. |
The underlying issue has been resolved in |
Awesome! Thanks @kazupon for modifying |
Describe the bug
We're @nuxtjs/i18n running into an issue with the way paths are being normalized when the paths contain query parameters with (more than one)
../
.vite/packages/vite/src/node/utils.ts
Line 210 in df77991
I understand that
path.posix.normalize
tries to make sense of the path containing../
, but in our case it breaks the way files are being resolved later on. I noticed that therollup
plugin@rollup/plugin-node-resolve
had a similar issue and fixed it by splitting the query parameters before resolving a path.This is what is happening:
I would think losing the query parameters or it influencing the path inside
normalizePath
is not intentional, but if it is, then do you have suggestions as to how to work around this? I would be happy to open a PR to implement a similar fix to the one referenced.Reproduction
https://stackblitz.com/edit/vitejs-vite-ejipxg?file=main.js
Steps to reproduce
Using imports with a query parameters containing more than one
../
, as seen in the reproduction,import viteLogo from '/vite.svg?target=../../';
will fail to resolve.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: