-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix: load esm vite config without a temporary file #17894
Conversation
Run & review this pull request in StackBlitz Codeflow. |
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.ts Before
After
In 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.register
approachdata:
import for the same content