-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
vite:resolve
plugin incorrectly resolves knownJsSrcRE
files from root
#4161
Comments
I tested this on macos on both Vite 2.4.1 and 2.8.6, and it seems to be working for me:
So it seems like a Windows only issue |
I tested this on windows on Vite 2.4.1 and 2.9.5 and I was not able to reproduce it.
|
Or does it mean vite/packages/vite/src/node/plugins/resolve.ts Lines 237 to 241 in 434bb5c
|
Describe the bug
vite/packages/vite/src/node/utils.ts
Line 109 in 98d95e3
When attempting to access any files with an extension that matches the
knownJsSrcRE
regex, thevite:resolve
plugin attempts to load them from the root of the filesystem. The following code in the plugin is the branch taken by such files.vite/packages/vite/src/node/plugins/resolve.ts
Lines 120 to 128 in 98d95e3
If the file exists at root and does not exist in the static assets directory, the plugin will resolve to the root file.
Reproduction
Add a
test.svelte
file at the root. Then, initialize a vanilla Vite template and run Vite in debug mode.Visit http://localhost:3000/test.svelte
The file is not loaded in an environment with no plugins, but combined with plugins such as
vite-plugin-svelte
it actually loads the file from root and resolves it ifserver.fs.strict
is disabled, taking priority over source code (though lower priority than the static asset public directory).System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: