vite:resolve
plugin incorrectly resolves knownJsSrcRE
files from root
#4161
Labels
bug
Something isn't working
p3-downstream-blocker 🔨
Blocking the downstream ecosystem to work properly (priority)
windows only
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: