fix: load esm vite config without a temporary file#17894
fix: load esm vite config without a temporary file#17894hi-ogawa wants to merge 16 commits intovitejs:mainfrom
Conversation
|
|
|
I'm checking how errors look like and this change might degrade DX heavily. While we can strip the error stack when the error is thrown during config loading, it's probably difficult to deal with the case where errors are thrown by plugins written directly inside the config file. I added a simple example in pnpm -C playground/config/packages/entry exec vite build -c vite.config.error-plugin.tsBeforeAfterIn order to handle this, we'll probably need to customize |
|
I'm personally not very comfortable with using a global function to handle the dynamic imports, and the stack trace issue also feels like a can of worms. We're switching tradeoffs than might open up issues for a different set of users. It's a bit unfortunate that runtimes until now don't provide the utilites we need to load config files. But maybe there's still some other things we could do:
|
|
I agree and personally stacktrace is a huge blocker since people iterate plugins development inside bundled config and see errors coming from there. I wanted to test out |
Node can |
|
They don't have a way to disable the cache recursively and track the files loaded to be watched for changes, so not really a 1:1 feature parity with the current config loading approach. It might not be crucial for some folks though hence I was working on a flag to enable direct import, but with the other PR now merged there isn't a strong usecase now. |


Description
Closes #13267
Closes #9470
This PR revives #13269 with a fix for arbitrary dynamic imports.
As explained in #13267 (comment), the previous PR #13269 was reverted due to a regression #13730. This PR handles the dynamic import issue by replacing
import(anything)with__vite_config_import_helper__(configFile, anything)to implement current behavior.todo
module.registerapproachdata:import for the same content