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

Support ava.config.mjs files #2346

Closed
novemberborn opened this issue Jan 5, 2020 · 2 comments · Fixed by #2629
Closed

Support ava.config.mjs files #2346

novemberborn opened this issue Jan 5, 2020 · 2 comments · Fixed by #2629
Assignees

Comments

@novemberborn
Copy link
Member

AVA recognizes ava.config.mjs files but refuses to load them. Let's fix this!

See the code here:

throw new Error(`AVA cannot yet load ${fileForErrorMessage} files`);

Of course import() is only available on Node.js 13. This should fail gracefully on Node.js 10 and 12.

import() is asynchronous. The loadConfig() method should still return synchronously when loading other files.

The documentation needs to be updated to explain when .mjs config files make sense and when users should use .cjs or .js files. Mostly this is to do with ESLint compatibility (since rules must currently be synchronous).

@novemberborn novemberborn mentioned this issue Jan 5, 2020
12 tasks
@arlac77
Copy link
Contributor

arlac77 commented Feb 4, 2020

Why not switching to async loadConfig() ?

@novemberborn
Copy link
Member Author

This is to do with ESLint compatibility (since rules must currently be synchronous).

@novemberborn novemberborn self-assigned this Dec 31, 2020
@novemberborn novemberborn linked a pull request Jan 1, 2021 that will close this issue
novemberborn added a commit that referenced this issue Jan 1, 2021
* When worker threads are available, support asynchronous configuration loading in the ESLint plugin helper

* Experimental implementation of next-generation configuration loading. This adds support for `.mjs` files, fixing #2346. I've removed the special handling of `ava.config.js` files, relying on Node.js to follow the package type instead. We now also support asynchronous factories.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants