Skip to content
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

Allow configuration to return a promise (async-friendly) #614

Closed
zachleat opened this issue Jul 16, 2019 · 5 comments
Closed

Allow configuration to return a promise (async-friendly) #614

zachleat opened this issue Jul 16, 2019 · 5 comments
Labels
enhancement feature: 🛠 configuration Related to Eleventy’s Configuration file feature: esm Related to supporting ES Modules (in parallel to CommonJS)

Comments

@zachleat
Copy link
Member

zachleat commented Jul 16, 2019

More information at #612 by @Munter

I attempted to use an async function in .eleventy.js because I wanted to try something depending on disk access, and usually do those things async. It turned out everything I tried to configure didn't work. The reason for this was that the config resolution doesn't handle async or promises, and just went ahead and merged my returned promise with the default config.

Right now this isn’t possible, this issue suggests that it should be:

module.exports = async function(eleventyConfig) {};

The problem here is that the config is used in constructors all over the code base (which are not async friendly).

@zachleat zachleat added enhancement needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. labels Jul 16, 2019
@zachleat
Copy link
Member Author

This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open.

View the enhancement backlog here. Don’t forget to upvote the top comment with 👍!

@zachleat
Copy link
Member Author

zachleat commented Mar 18, 2020

If I could vote twice I’d vote again since this bit me just now (the error message that @Munter added was so good though)

@MadeByMike MadeByMike mentioned this issue Sep 27, 2020
2 tasks
@zachleat zachleat changed the title Allow configuration to return a promise Allow configuration to return a promise (async-friendly) Jan 3, 2022
@zachleat
Copy link
Member Author

zachleat commented Jan 3, 2022

This was attempted in #1429 but didn’t make it in (it was my fault)

@zachleat zachleat added the feature: 🛠 configuration Related to Eleventy’s Configuration file label Jan 3, 2022
@zachleat zachleat added feature: esm Related to supporting ES Modules (in parallel to CommonJS) and removed needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. labels Aug 28, 2023
@zachleat zachleat added this to the Eleventy 3.0.0 milestone Aug 28, 2023
@zachleat
Copy link
Member Author

zachleat commented Aug 28, 2023

This is tied to ESM support, which includes top-level await (milestoning to 3.0 and removing from the enhancement queue)

@zachleat
Copy link
Member Author

Fixed in PR #3074

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature: 🛠 configuration Related to Eleventy’s Configuration file feature: esm Related to supporting ES Modules (in parallel to CommonJS)
Projects
None yet
Development

No branches or pull requests

1 participant