question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow asynchronous config hooks for plugins

See original GitHub issue

Clear 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
Snugugcommented, Jul 7, 2021

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.

1reaction
Snugugcommented, Jul 2, 2021

Yup that’s what I’m thinking too. I’ll do that

On Jul 2, 2021, at 8:05 AM, patak @.***> wrote:

That is indeed strange. I think the best is to try to create a minimal reproduction and open a new bug report.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compiler Hooks | webpack
Executes a plugin during watch mode after a new compilation is triggered but before the compilation is actually started. Callback Parameters: compiler ...
Read more >
Plugin hooks - Datasette documentation
This hook allows you to create new providers for the datasette publish command. Datasette uses this hook internally to implement the default cloudrun...
Read more >
Async hooks | Node.js v19.3.0 Documentation
asyncHook.enable(); // Disable listening for new asynchronous events. ... Returns: <AsyncHook> Instance used for disabling and enabling hooks.
Read more >
Creating Apollo Server plugins - Apollo GraphQL Docs
Just like the event handlers themselves, these end hooks are async functions (except for the end hook for willResolveField ). End hooks are...
Read more >
Hooks Guide - Apache Cordova
Cordova hooks allow you to perform special activities around cordova commands. ... hooks from config.xml running before plugin hooks from plugins/.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found