Allow asynchronous config hooks for plugins
See original GitHub issueClear and concise description of the problem
I’m attempting to author a Vite plugin for 11ty and am running into issues properly setting the config. Eleventy’s Node API is entirely asynchronous, and in order to properly set the config for what files should be added to Rollup during build I need to compile the files. Because 11ty is async, I’m hitting a race condition where the files aren’t written to disk by the time Vite is trying to find them to compile them. If the config
hook could be asynchronous instead of synchronous, like configResolved
is, this would be straightforward to resolve.
Suggested solution
Allow the config
hook to accept, and wait for completion from, an async
function
Alternative
I’ve tried using deasync
but https://github.com/abbr/deasync/issues/21 prevents it from working for my usecase
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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
In case anyone comes across this later and is curious of the resolution, after being unable to create a minimal test case to reproduce this, I checked all my dependencies and saw i was on Vite 2.2. Upgrading to 2.4 resolved the sync/async race condition I was seeing, so I’m guessing async config landed in 2.3.
Yup that’s what I’m thinking too. I’ll do that