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

Migrate CodeceptJS to ESM (Top-level await) #4185

Open
danielhelen opened this issue Feb 9, 2024 · 3 comments
Open

Migrate CodeceptJS to ESM (Top-level await) #4185

danielhelen opened this issue Feb 9, 2024 · 3 comments
Labels

Comments

@danielhelen
Copy link

What are you trying to achieve?

I need to use top-level await to retrieve config from AWS and other APIs but CodeceptJS seems completely incompatible with ES modules. Top-level await is simply not possible in CommonJS. Are there any plans to support ES modules?

What do you get instead?

If you set "type": "module" in package.json you get this error:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/REDACTED/config/codecept.conf.js from /Users/REDACTED/node_modules/codeceptjs/lib/config.js not supported.
Instead change the require of codecept.conf.js in /Users/REDACTED/node_modules/codeceptjs/lib/config.js to a dynamic import() which is available in all CommonJS modules.
    at loadConfigFile (/Users/REDACTED/node_modules/codeceptjs/lib/config.js:160:26)
    at Config.load (/Users/REDACTED/node_modules/codeceptjs/lib/config.js:91:14)
    at module.exports.getConfig (/Users/REDACTED/node_modules/codeceptjs/lib/command/utils.js:14:33)
    at module.exports (/Users/REDACTED/node_modules/codeceptjs/lib/command/run.js:18:16)
    at Command.<anonymous> (/Users/REDACTED/node_modules/codeceptjs/bin/codecept.js:9:11)

Details

  • CodeceptJS version: 3.5.13-beta.3
  • NodeJS Version: v20.10.0
  • Operating System: MacOS Ventura
@DavertMik
Copy link
Contributor

@danielhelen at this moment this means to rewrite CodeceptJS completely and I don't think we have enough resources to handle this task.

@DavertMik
Copy link
Contributor

Actually we can try this codemod, which can make migration faster

https://github.com/azu/commonjs-to-es-module-codemod

@DavertMik DavertMik changed the title Top-level await Migrate CodeceptJS to ESM (Top-level await) Feb 17, 2024
@DavertMik
Copy link
Contributor

#4229 We are working on it!

@DavertMik DavertMik added the 4.0 label Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants