Fix top level await requireOrImport not trying import()
after failed require
#269
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 toimport()
since the error code changed. Previously gulp would detect the error and attempt to useimport()
.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