-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Clear and concise description of the problem
I've tried to replace my current bundler (rollup) with vite and got stuck with path resolution.
My setup is quite basic. I'm using absolute import paths in my project:
import { something } from 'someDir/someFile'; The relative file system path of this import would be ./src/someDir/someFile.
As you can see, I can omit the ./src/ part here. I did this by using the moduleDirectories prop from the @rollup/plugin-node-resolve. Unfortunately vite isn't providing this functionality out of the box which is in my opinion a key feature for every bundler.
Bundlers which are providing this feature:
- Webpack with resolve.modules
- esbuild with nodePaths
- Rollup with @rollup/plugin-node-resolve and moduleDirectories
This is also supported by Eslint with the eslint-import-resolver-node plugin (moduleDirectory option)
Suggested solution
Provide this feature "natively" in the vite config. Something like resolve.moduleDirectories or resolve.nodePaths.
Alternative
It seems like you can use the @rollup/plugin-node-resolve plugin here, but it still feels weird to have this key feature not supported. Additionally since vite is doing quite some resolve logic itself I'm in fear of something not working properly by using the plugin.
You could also use aliases, but is this the "right" way? - With this solution I would be forced to rewrite all of my imports.
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.