Default to `--configLoader=native`
Description
Currently there are multiple config loaders: https://github.com/vitejs/vite/discussions/20162 Each option has its own downsides and upsides.
Suggested solution
We think the native config loader (--configLoader=native) is the least confusing one among all the loaders and plan to default to it.
While it has some stricter behaviors like extension-less imports are disallowed, other tools will likely to use the native loading approach for configs, and thus the limitation is less surprising than the other approaches. By switching to the native loader, #5370 and #19730 can also be solved (these were some of the downsides of the bundle loader). This is also helpful for other Vite stack tools and potentially other tools as it would be easier to share the same loading mechanism easily.
Alternative
No response
Additional context
To the ease the migration, our plan is to:
- Set
moduleResolution: 'nodenext' in tsconfig.node.json of create-vite (erasableSyntaxOnly: true is already set). - Finish https://github.com/vitejs/vite/pull/19374
- Add runtime warnings to configs with
__dirname / __filename, extension-less imports. Update docs to recommend moduleResolution: 'nodenext' + erasableSyntaxOnly: true for configs. - (Vite 9) Default to
--configLoader native. Deprecate other config loaders. - (Vite 10) Remove other config loaders and
--configLoader flag.
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.
Source: vitejs/vite