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

Fix top level await requireOrImport not trying import() after failed require #269

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

epelc
Copy link

@epelc epelc commented Dec 31, 2024

Fixes #268 which is broken on node v22.12.0 and later(works on <= v22.11.0). Gulp cli was trying to use require(), failing and not trying to fallback to import() since the error code changed. Previously gulp would detect the error and attempt to use import().

This makes it detect the new error code in node v22.12.0 and later. Keeps the old behavior to support older node versions as well.

See node change log which describes the changes that lead to this.

https://nodejs.org/en/blog/release/v22.12.0#requireesm-is-now-enabled-by-default

  - supports node v22.12.0 and later when using top level await
@epelc epelc changed the title Fix top level await not using import() Fix top level await requireOrImport not trying import() after failed require Dec 31, 2024
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.

Node 22 ERR_REQUIRE_ASYNC_MODULE if gulpfile.mjs contains top-level await
1 participant