Skip to content

improve(config): Support cjs file extensions for config file #3052

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

Merged
merged 1 commit into from
Sep 23, 2021

Conversation

kalvenschraut
Copy link
Contributor

I am attempting to set my project to be a esm module by using the package.json property "type" with the value of "module".
Noticed codecept didn't support importing esm so I changed all of my acceptance testing files to be commonjs files denoted with the .cjs file extension. Need to add this extension to the list of checked extensions so the config file will be loaded.

On a side note is there any plan to support esm modules. Would have to swap to use dynamic imports or first try to use require then fallback to dynamic import if the error is "ERR_REQUIRE_ESM". Mocha currently supports esm modules but have to use loadFiles Aync instead of loadFiles. I looked at your require code a bit and wasn't sure how to best handle having to deal with the fact dynamic imports return a promise.

@Arhell Arhell requested a review from DavertMik September 23, 2021 02:21
@DavertMik
Copy link
Contributor

On a side note is there any plan to support esm modules. Would have to swap to use dynamic imports or first try to use require then fallback to dynamic import if the error is "ERR_REQUIRE_ESM". Mocha currently supports esm modules but have to use loadFiles Aync instead of loadFiles. I looked at your require code a bit and wasn't sure how to best handle having to deal with the fact dynamic imports return a promise.

No plans at this moment. But help in this direction is highly appreciated.
If you have ideas for the transition plan - please share it.
We can discuss it here or in Slack.

@DavertMik
Copy link
Contributor

Thanks, merging!

@DavertMik DavertMik merged commit ff3e7c2 into codeceptjs:3.x Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants