diff --git a/packages/next-on-pages/src/buildApplication/processVercelFunctions/build.ts b/packages/next-on-pages/src/buildApplication/processVercelFunctions/build.ts index 4c79cd4ef..d37a4bb20 100644 --- a/packages/next-on-pages/src/buildApplication/processVercelFunctions/build.ts +++ b/packages/next-on-pages/src/buildApplication/processVercelFunctions/build.ts @@ -101,21 +101,24 @@ type RelativePathOpts = { * breaks at runtime. The following fixes this by updating the dynamic require to a standard esm * import from the built-in module. * - * This applies to `require("node:*")` and `require("cloudflare:*")`. + * This applies to `require("node:*")`, `require("cloudflare:*")`, and `require("async_hooks")`. */ export const builtInModulesPlugin: Plugin = { name: 'built-in:modules', setup(build) { - build.onResolve({ filter: /^(node|cloudflare):/ }, ({ kind, path }) => { - /** - * This plugin converts `require(":*")` calls, those are the only ones that need - * updating (esm imports to ":*" are totally valid), so here we tag with the - * built-in-modules namespace only imports that are require calls. - */ - return kind === 'require-call' - ? { path, namespace: 'built-in-modules' } - : undefined; - }); + build.onResolve( + { filter: /^(node:|cloudflare:|async_hooks)/ }, + ({ kind, path }) => { + /** + * This plugin converts `require(":*")` calls, those are the only ones that need + * updating (esm imports to ":*" are totally valid), so here we tag with the + * built-in-modules namespace only imports that are require calls. + */ + return kind === 'require-call' + ? { path, namespace: 'built-in-modules' } + : undefined; + }, + ); /** * We convert the imports we tagged with the built-in-modules namespace so that instead of