feat: Support top-level await on Node 22.12+#269
Merged
phated merged 3 commits intogulpjs:masterfrom Jun 1, 2025
Merged
Conversation
import()import() after failed require
|
I can confirm this works for me and solves the problems I was having reported in this issue: #267 Is there anything stopping this being merged? |
30 tasks
Member
|
I need to figure out a regression test for this because CI isn't failing in #272 when it should be. |
Member
|
It looks like this will cause the failure: const dynamicNoop = await Promise.resolve(function noop(cb) {
cb();
});
export const registered = dynamicNoop;
export function exported(){};
export const string = 'no function'; |
import() after failed require- supports node v22.12.0 and later when using top level await
174a192 to
fd1742b
Compare
Contributor
Author
Thanks! Excited to get this in. Been blocking a node upgrade. Gulp works really well for auxiliary build steps around modern angular. |
|
Thanks for getting this merged and released 🙏 |
|
Node version 25.2.1 and I'm seeing this error, despite using the gulp & gulp-cli versions where this was supposedly merged... I can't work it out: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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