-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
No fallback to index.js when importing a directory using an alias #15858
Comments
It looks like newly introduced https://stackblitz.com/edit/github-d5e7nn?file=src%2Fmain.js // fails
import * as lib1 from '@/utils/'; // @ alias is rewritten to absolute path
console.log({ lib1 });
// others all work
import * as lib2 from '@/utils';
console.log({ lib2 });
import * as lib3 from '@/utils/index.js';
console.log({ lib3 });
// for relative path, `path.resolve` (which removes trailing slash) happens before reaching fs caching, so this doesn't manifest the issue
import * as lib4 from './utils/';
console.log({ lib4 });
import * as lib5 from './utils';
console.log({ lib5 });
import * as lib6 from './utils///././//'; // still normalized to the same "utils"
console.log({ lib6 }); Quick workaround would be to disable export default defineConfig({
server: {
fs: {
cachedChecks: false,
},
},
}); I think non-cached version (e.g plain NodeJS's |
I can confirm that disabling cachedChecks works. Good workaround in my case, until this minor issue is resolved. |
Describe the bug
Importing a directory using
import
won't fallback to the index.js file anymore.Get the following error:
I created a very simple repo for an easy reproduction.
I noticed that the issue started at version 5.1.0, more specifically with version 5.1.0-beta.4.
Reproduction
https:/charlesmass2/vite-index-fallback-fail
Steps to reproduce
Run
npm install
followed bynpm run dev
System Info
This is also reproduced in Alpine docker container.
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: