@@ -368,6 +371,10 @@ impl Fold for NextDynamicPatcher {
...
@@ -368,6 +371,10 @@ impl Fold for NextDynamicPatcher {
ifhas_ssr_false
ifhas_ssr_false
&&self.is_server_compiler
&&self.is_server_compiler
&&!self.is_react_server_layer
&&!self.is_react_server_layer
// When it's not prefer to picking up ESM, as it's in the pages router, we don't need to do it as it doesn't need to enter the non-ssr module.
// Also transforming it to `require.resolveWeak` and with ESM import, like require.resolveWeak(esm asset) is not available as it's commonjs importing ESM.
&&self.prefer_esm
// Only use `require.resolveWebpack` to decouple modules for webpack,
// Only use `require.resolveWebpack` to decouple modules for webpack,