Skip to content

Conversation

@gnoff
Copy link
Contributor

@gnoff gnoff commented Oct 24, 2025

These scopes aren't fully Next.js environments and can't access many Next.js APIs. In the future this might change but for now we will exclude the next-js condition when bundling for these entrypoints so that 3rd parties that target Next.js can do so with the expectation that regardless of what environment they are running in the full suite of Next.js libraries they support will work.

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team. tests Turbopack Related to Turbopack with Next.js. type: next labels Oct 24, 2025
@gnoff gnoff force-pushed the refine-next-js-condition branch from fff8cea to ae564ae Compare October 24, 2025 19:39
Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments:

test/lib/next-modes/base.ts (lines 159-162):
The code calls fs.lstat() without error handling, which will throw an ENOENT error if the file doesn't exist yet. This will cause writeOverrideFiles() to fail when trying to override a non-existent file path.

View Details
📝 Patch Details
diff --git a/test/lib/next-modes/base.ts b/test/lib/next-modes/base.ts
index 786a5aee9a..f740472404 100644
--- a/test/lib/next-modes/base.ts
+++ b/test/lib/next-modes/base.ts
@@ -156,9 +156,17 @@ export class NextInstance {
           await fs.mkdir(path.dirname(outputFilename), { recursive: true })
           await fs.writeFile(outputFilename, item)
         } else {
-          const existingStat = await fs.lstat(outputFilename)
-          if (existingStat.isFile() || existingStat.isSymbolicLink()) {
-            await fs.unlink(outputFilename)
+          await fs.mkdir(path.dirname(outputFilename), { recursive: true })
+          try {
+            const existingStat = await fs.lstat(outputFilename)
+            if (existingStat.isFile() || existingStat.isSymbolicLink()) {
+              await fs.unlink(outputFilename)
+            }
+          } catch (err: any) {
+            // File doesn't exist yet, that's fine - we'll create it
+            if (err.code !== 'ENOENT') {
+              throw err
+            }
           }
           await fs.cp(item.fsPath, outputFilename, { recursive: true })
         }

Analysis

Unhandled ENOENT error in writeFiles() when handling FileRef items

What fails: The writeFiles() method in test/lib/next-modes/base.ts throws an uncaught ENOENT error when initializing files with FileRef items that don't exist yet

How to reproduce: Create a test configuration with files containing a FileRef for a non-existent path:

new NextInstance({
  files: {
    'newfile': new FileRef('/some/source/path')
  }
})

This triggers writeInitialFiles()writeFiles() which calls fs.lstat(outputFilename) without error handling. Since the file doesn't exist yet, it throws: Error: ENOENT: no such file or directory, lstat '[path]'

Result: Function throws uncaught ENOENT error, preventing initialization

Expected: Should gracefully handle non-existent files, creating them as needed (or checking existence before attempting to remove)

Reference: Per Node.js fs.lstat documentation, fs.lstat() throws an error when the file doesn't exist, rather than returning undefined

@ijjk
Copy link
Member

ijjk commented Oct 24, 2025

Tests Passed

@ijjk
Copy link
Member

ijjk commented Oct 24, 2025

Stats from current PR

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
buildDuration 22.5s 20.5s N/A
buildDurationCached 18.8s 15.5s N/A
nodeModulesSize 454 MB 454 MB ⚠️ +3.33 kB
nextStartRea..uration (ms) 695ms 717ms N/A
Client Bundles (main, webpack)
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
1916.HASH.js gzip 169 B 169 B
9056-HASH.js gzip 54.7 kB 54.3 kB N/A
9225-HASH.js gzip 5.32 kB 5.32 kB N/A
c57d0559-HASH.js gzip 62.1 kB 62 kB N/A
framework-HASH.js gzip 59.8 kB 59.8 kB
main-app-HASH.js gzip 256 B 255 B N/A
main-HASH.js gzip 39.8 kB 39.8 kB N/A
webpack-HASH.js gzip 1.69 kB 1.69 kB N/A
Overall change 60 kB 60 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Overall change 39.4 kB 39.4 kB
Client Pages
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
_app-HASH.js gzip 193 B 194 B N/A
_error-HASH.js gzip 182 B 182 B
css-HASH.js gzip 334 B 334 B
dynamic-HASH.js gzip 1.8 kB 1.81 kB N/A
edge-ssr-HASH.js gzip 256 B 254 B N/A
head-HASH.js gzip 350 B 351 B N/A
hooks-HASH.js gzip 384 B 384 B
image-HASH.js gzip 4.79 kB 4.77 kB N/A
index-HASH.js gzip 259 B 259 B
link-HASH.js gzip 2.5 kB 2.5 kB N/A
routerDirect..HASH.js gzip 318 B 320 B N/A
script-HASH.js gzip 386 B 388 B N/A
withRouter-HASH.js gzip 315 B 314 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 1.26 kB 1.26 kB
Client Build Manifests
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
_buildManifest.js gzip 716 B 720 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
index.html gzip 524 B 521 B N/A
link.html gzip 538 B 537 B N/A
withRouter.html gzip 519 B 518 B N/A
Overall change 0 B 0 B
Edge SSR bundle Size Overall increase ⚠️
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
edge-ssr.js gzip 128 kB 128 kB N/A
page.js gzip 260 kB 260 kB ⚠️ +255 B
Overall change 260 kB 260 kB ⚠️ +255 B
Middleware size
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
middleware-b..fest.js gzip 636 B 638 B N/A
middleware-r..fest.js gzip 156 B 156 B
middleware.js gzip 32.9 kB 32.9 kB N/A
edge-runtime..pack.js gzip 846 B 846 B
Overall change 1 kB 1 kB
Next Runtimes
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
app-page-exp...dev.js gzip 295 kB 295 kB N/A
app-page-exp..prod.js gzip 161 kB 161 kB
app-page-tur...dev.js gzip 295 kB 295 kB
app-page-tur..prod.js gzip 161 kB 161 kB
app-page-tur...dev.js gzip 291 kB 291 kB
app-page-tur..prod.js gzip 159 kB 159 kB
app-page.run...dev.js gzip 292 kB 292 kB
app-page.run..prod.js gzip 159 kB 159 kB
app-route-ex...dev.js gzip 70.8 kB 70.8 kB
app-route-ex..prod.js gzip 49.4 kB 49.4 kB
app-route-tu...dev.js gzip 70.8 kB 70.8 kB
app-route-tu..prod.js gzip 49.4 kB 49.4 kB
app-route-tu...dev.js gzip 70.4 kB 70.4 kB
app-route-tu..prod.js gzip 49.2 kB 49.2 kB
app-route.ru...dev.js gzip 70.4 kB 70.4 kB
app-route.ru..prod.js gzip 49.1 kB 49.1 kB
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 328 B 328 B
dist_client_...dev.js gzip 320 B 320 B
dist_client_...dev.js gzip 318 B 318 B
pages-api-tu...dev.js gzip 43.3 kB 43.3 kB
pages-api-tu..prod.js gzip 33.1 kB 33.1 kB
pages-api.ru...dev.js gzip 43.3 kB 43.3 kB
pages-api.ru..prod.js gzip 33.1 kB 33.1 kB
pages-turbo....dev.js gzip 52.8 kB 52.8 kB
pages-turbo...prod.js gzip 40.1 kB 40.1 kB
pages.runtim...dev.js gzip 52.8 kB 52.8 kB
pages.runtim..prod.js gzip 40 kB 40 kB
server.runti..prod.js gzip 78.9 kB 78.9 kB
Overall change 2.42 MB 2.42 MB
build cache Overall increase ⚠️
vercel/next.js canary gnoff/next.js refine-next-js-condition Change
0.pack gzip 3.25 MB 3.25 MB N/A
index.pack gzip 93.2 kB 94.4 kB ⚠️ +1.22 kB
Overall change 93.2 kB 94.4 kB ⚠️ +1.22 kB
Diff details
Diff for page.js

Diff too large to display

Diff for middleware.js

Diff too large to display

Diff for edge-ssr.js
failed to diff
Diff for css-HASH.js
@@ -1,7 +1,31 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [9813],
   {
-    /***/ 3593: /***/ (
+    /***/ 6395: /***/ (module) => {
+      // extracted by mini-css-extract-plugin
+      module.exports = { helloWorld: "css_helloWorld__aUdUq" };
+
+      /***/
+    },
+
+    /***/ 6471: /***/ (
+      __unused_webpack_module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      (window.__NEXT_P = window.__NEXT_P || []).push([
+        "/css",
+        function () {
+          return __webpack_require__(8558);
+        },
+      ]);
+      if (false) {
+      }
+
+      /***/
+    },
+
+    /***/ 8558: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -15,7 +39,7 @@
       /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
         __webpack_require__(1503);
       /* harmony import */ var _css_module_css__WEBPACK_IMPORTED_MODULE_1__ =
-        __webpack_require__(7634);
+        __webpack_require__(6395);
       /* harmony import */ var _css_module_css__WEBPACK_IMPORTED_MODULE_1___default =
         /*#__PURE__*/ __webpack_require__.n(
           _css_module_css__WEBPACK_IMPORTED_MODULE_1__
@@ -34,37 +58,13 @@
 
       /***/
     },
-
-    /***/ 4569: /***/ (
-      __unused_webpack_module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      (window.__NEXT_P = window.__NEXT_P || []).push([
-        "/css",
-        function () {
-          return __webpack_require__(3593);
-        },
-      ]);
-      if (false) {
-      }
-
-      /***/
-    },
-
-    /***/ 7634: /***/ (module) => {
-      // extracted by mini-css-extract-plugin
-      module.exports = { helloWorld: "css_helloWorld__aUdUq" };
-
-      /***/
-    },
   },
   /******/ (__webpack_require__) => {
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(4569)
+      __webpack_exec__(6471)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for dynamic-HASH.js
@@ -1,7 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [2291],
   {
-    /***/ 1033: /***/ (
+    /***/ 431: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/dynamic",
         function () {
-          return __webpack_require__(2283);
+          return __webpack_require__(8084);
         },
       ]);
       if (false) {
@@ -18,233 +18,7 @@
       /***/
     },
 
-    /***/ 2283: /***/ (
-      __unused_webpack_module,
-      __webpack_exports__,
-      __webpack_require__
-    ) => {
-      "use strict";
-      __webpack_require__.r(__webpack_exports__);
-      /* harmony export */ __webpack_require__.d(__webpack_exports__, {
-        /* harmony export */ __N_SSP: () => /* binding */ __N_SSP,
-        /* harmony export */ default: () => __WEBPACK_DEFAULT_EXPORT__,
-        /* harmony export */
-      });
-      /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
-        __webpack_require__(1503);
-      /* harmony import */ var next_dynamic__WEBPACK_IMPORTED_MODULE_1__ =
-        __webpack_require__(4939);
-      /* harmony import */ var next_dynamic__WEBPACK_IMPORTED_MODULE_1___default =
-        /*#__PURE__*/ __webpack_require__.n(
-          next_dynamic__WEBPACK_IMPORTED_MODULE_1__
-        );
-
-      const DynamicHello = next_dynamic__WEBPACK_IMPORTED_MODULE_1___default()(
-        () =>
-          __webpack_require__
-            .e(/* import() */ 1916)
-            .then(__webpack_require__.bind(__webpack_require__, 1916))
-            .then((mod) => mod.Hello),
-        {
-          loadableGenerated: {
-            webpack: () => [/*require.resolve*/ 1916],
-          },
-        }
-      );
-      const Page = () =>
-        /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(
-          react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment,
-          {
-            children: [
-              /*#__PURE__*/ (0,
-              react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p", {
-                children: "testing next/dynamic size",
-              }),
-              /*#__PURE__*/ (0,
-              react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(
-                DynamicHello,
-                {}
-              ),
-            ],
-          }
-        );
-      var __N_SSP = true;
-      /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = Page;
-
-      /***/
-    },
-
-    /***/ 4939: /***/ (
-      module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      module.exports = __webpack_require__(5121);
-
-      /***/
-    },
-
-    /***/ 5121: /***/ (module, exports, __webpack_require__) => {
-      "use strict";
-
-      Object.defineProperty(exports, "__esModule", {
-        value: true,
-      });
-      0 && 0;
-      function _export(target, all) {
-        for (var name in all)
-          Object.defineProperty(target, name, {
-            enumerable: true,
-            get: all[name],
-          });
-      }
-      _export(exports, {
-        /**
-         * This function lets you dynamically import a component.
-         * It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood.
-         *
-         * Read more: [Next.js Docs: `next/dynamic`](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic)
-         */ default: function () {
-          return dynamic;
-        },
-        noSSR: function () {
-          return noSSR;
-        },
-      });
-      const _interop_require_default = __webpack_require__(1532);
-      const _jsxruntime = __webpack_require__(1503);
-      const _react = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(2223)
-      );
-      const _loadablesharedruntime = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(7622)
-      );
-      const isServerSide = "object" === "undefined";
-      // Normalize loader to return the module as form { default: Component } for `React.lazy`.
-      // Also for backward compatible since next/dynamic allows to resolve a component directly with loader
-      // Client component reference proxy need to be converted to a module.
-      function convertModule(mod) {
-        return {
-          default: mod?.default || mod,
-        };
-      }
-      function noSSR(LoadableInitializer, loadableOptions) {
-        // Removing webpack and modules means react-loadable won't try preloading
-        delete loadableOptions.webpack;
-        delete loadableOptions.modules;
-        // This check is necessary to prevent react-loadable from initializing on the server
-        if (!isServerSide) {
-          return LoadableInitializer(loadableOptions);
-        }
-        const Loading = loadableOptions.loading;
-        // This will only be rendered on the server side
-        return () =>
-          /*#__PURE__*/ (0, _jsxruntime.jsx)(Loading, {
-            error: null,
-            isLoading: true,
-            pastDelay: false,
-            timedOut: false,
-          });
-      }
-      function dynamic(dynamicOptions, options) {
-        let loadableFn = _loadablesharedruntime.default;
-        let loadableOptions = {
-          // A loading component is not required, so we default it
-          loading: ({ error, isLoading, pastDelay }) => {
-            if (!pastDelay) return null;
-            if (false) {
-            }
-            return null;
-          },
-        };
-        // Support for direct import(), eg: dynamic(import('../hello-world'))
-        // Note that this is only kept for the edge case where someone is passing in a promise as first argument
-        // The react-loadable babel plugin will turn dynamic(import('../hello-world')) into dynamic(() => import('../hello-world'))
-        // To make sure we don't execute the import without rendering first
-        if (dynamicOptions instanceof Promise) {
-          loadableOptions.loader = () => dynamicOptions;
-          // Support for having import as a function, eg: dynamic(() => import('../hello-world'))
-        } else if (typeof dynamicOptions === "function") {
-          loadableOptions.loader = dynamicOptions;
-          // Support for having first argument being options, eg: dynamic({loader: import('../hello-world')})
-        } else if (typeof dynamicOptions === "object") {
-          loadableOptions = {
-            ...loadableOptions,
-            ...dynamicOptions,
-          };
-        }
-        // Support for passing options, eg: dynamic(import('../hello-world'), {loading: () => <p>Loading something</p>})
-        loadableOptions = {
-          ...loadableOptions,
-          ...options,
-        };
-        const loaderFn = loadableOptions.loader;
-        const loader = () =>
-          loaderFn != null
-            ? loaderFn().then(convertModule)
-            : Promise.resolve(convertModule(() => null));
-        // coming from build/babel/plugins/react-loadable-plugin.js
-        if (loadableOptions.loadableGenerated) {
-          loadableOptions = {
-            ...loadableOptions,
-            ...loadableOptions.loadableGenerated,
-          };
-          delete loadableOptions.loadableGenerated;
-        }
-        // support for disabling server side rendering, eg: dynamic(() => import('../hello-world'), {ssr: false}).
-        if (typeof loadableOptions.ssr === "boolean" && !loadableOptions.ssr) {
-          delete loadableOptions.webpack;
-          delete loadableOptions.modules;
-          return noSSR(loadableFn, loadableOptions);
-        }
-        return loadableFn({
-          ...loadableOptions,
-          loader: loader,
-        });
-      }
-      if (
-        (typeof exports.default === "function" ||
-          (typeof exports.default === "object" && exports.default !== null)) &&
-        typeof exports.default.__esModule === "undefined"
-      ) {
-        Object.defineProperty(exports.default, "__esModule", {
-          value: true,
-        });
-        Object.assign(exports.default, exports);
-        module.exports = exports.default;
-      } //# sourceMappingURL=dynamic.js.map
-
-      /***/
-    },
-
-    /***/ 5160: /***/ (
-      __unused_webpack_module,
-      exports,
-      __webpack_require__
-    ) => {
-      "use strict";
-      /* __next_internal_client_entry_do_not_use__  cjs */
-      Object.defineProperty(exports, "__esModule", {
-        value: true,
-      });
-      Object.defineProperty(exports, "LoadableContext", {
-        enumerable: true,
-        get: function () {
-          return LoadableContext;
-        },
-      });
-      const _interop_require_default = __webpack_require__(1532);
-      const _react = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(2223)
-      );
-      const LoadableContext = _react.default.createContext(null);
-      if (false) {
-      } //# sourceMappingURL=loadable-context.shared-runtime.js.map
-
-      /***/
-    },
-
-    /***/ 7622: /***/ (
+    /***/ 2699: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -286,7 +60,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
       const _react = /*#__PURE__*/ _interop_require_default._(
         __webpack_require__(2223)
       );
-      const _loadablecontextsharedruntime = __webpack_require__(5160);
+      const _loadablecontextsharedruntime = __webpack_require__(3785);
       function resolve(obj) {
         return obj && obj.default ? obj.default : obj;
       }
@@ -518,13 +292,239 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
 
       /***/
     },
+
+    /***/ 3785: /***/ (
+      __unused_webpack_module,
+      exports,
+      __webpack_require__
+    ) => {
+      "use strict";
+      /* __next_internal_client_entry_do_not_use__  cjs */
+      Object.defineProperty(exports, "__esModule", {
+        value: true,
+      });
+      Object.defineProperty(exports, "LoadableContext", {
+        enumerable: true,
+        get: function () {
+          return LoadableContext;
+        },
+      });
+      const _interop_require_default = __webpack_require__(1532);
+      const _react = /*#__PURE__*/ _interop_require_default._(
+        __webpack_require__(2223)
+      );
+      const LoadableContext = _react.default.createContext(null);
+      if (false) {
+      } //# sourceMappingURL=loadable-context.shared-runtime.js.map
+
+      /***/
+    },
+
+    /***/ 6828: /***/ (module, exports, __webpack_require__) => {
+      "use strict";
+
+      Object.defineProperty(exports, "__esModule", {
+        value: true,
+      });
+      0 && 0;
+      function _export(target, all) {
+        for (var name in all)
+          Object.defineProperty(target, name, {
+            enumerable: true,
+            get: all[name],
+          });
+      }
+      _export(exports, {
+        /**
+         * This function lets you dynamically import a component.
+         * It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood.
+         *
+         * Read more: [Next.js Docs: `next/dynamic`](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic)
+         */ default: function () {
+          return dynamic;
+        },
+        noSSR: function () {
+          return noSSR;
+        },
+      });
+      const _interop_require_default = __webpack_require__(1532);
+      const _jsxruntime = __webpack_require__(1503);
+      const _react = /*#__PURE__*/ _interop_require_default._(
+        __webpack_require__(2223)
+      );
+      const _loadablesharedruntime = /*#__PURE__*/ _interop_require_default._(
+        __webpack_require__(2699)
+      );
+      const isServerSide = "object" === "undefined";
+      // Normalize loader to return the module as form { default: Component } for `React.lazy`.
+      // Also for backward compatible since next/dynamic allows to resolve a component directly with loader
+      // Client component reference proxy need to be converted to a module.
+      function convertModule(mod) {
+        return {
+          default: mod?.default || mod,
+        };
+      }
+      function noSSR(LoadableInitializer, loadableOptions) {
+        // Removing webpack and modules means react-loadable won't try preloading
+        delete loadableOptions.webpack;
+        delete loadableOptions.modules;
+        // This check is necessary to prevent react-loadable from initializing on the server
+        if (!isServerSide) {
+          return LoadableInitializer(loadableOptions);
+        }
+        const Loading = loadableOptions.loading;
+        // This will only be rendered on the server side
+        return () =>
+          /*#__PURE__*/ (0, _jsxruntime.jsx)(Loading, {
+            error: null,
+            isLoading: true,
+            pastDelay: false,
+            timedOut: false,
+          });
+      }
+      function dynamic(dynamicOptions, options) {
+        let loadableFn = _loadablesharedruntime.default;
+        let loadableOptions = {
+          // A loading component is not required, so we default it
+          loading: ({ error, isLoading, pastDelay }) => {
+            if (!pastDelay) return null;
+            if (false) {
+            }
+            return null;
+          },
+        };
+        // Support for direct import(), eg: dynamic(import('../hello-world'))
+        // Note that this is only kept for the edge case where someone is passing in a promise as first argument
+        // The react-loadable babel plugin will turn dynamic(import('../hello-world')) into dynamic(() => import('../hello-world'))
+        // To make sure we don't execute the import without rendering first
+        if (dynamicOptions instanceof Promise) {
+          loadableOptions.loader = () => dynamicOptions;
+          // Support for having import as a function, eg: dynamic(() => import('../hello-world'))
+        } else if (typeof dynamicOptions === "function") {
+          loadableOptions.loader = dynamicOptions;
+          // Support for having first argument being options, eg: dynamic({loader: import('../hello-world')})
+        } else if (typeof dynamicOptions === "object") {
+          loadableOptions = {
+            ...loadableOptions,
+            ...dynamicOptions,
+          };
+        }
+        // Support for passing options, eg: dynamic(import('../hello-world'), {loading: () => <p>Loading something</p>})
+        loadableOptions = {
+          ...loadableOptions,
+          ...options,
+        };
+        const loaderFn = loadableOptions.loader;
+        const loader = () =>
+          loaderFn != null
+            ? loaderFn().then(convertModule)
+            : Promise.resolve(convertModule(() => null));
+        // coming from build/babel/plugins/react-loadable-plugin.js
+        if (loadableOptions.loadableGenerated) {
+          loadableOptions = {
+            ...loadableOptions,
+            ...loadableOptions.loadableGenerated,
+          };
+          delete loadableOptions.loadableGenerated;
+        }
+        // support for disabling server side rendering, eg: dynamic(() => import('../hello-world'), {ssr: false}).
+        if (typeof loadableOptions.ssr === "boolean" && !loadableOptions.ssr) {
+          delete loadableOptions.webpack;
+          delete loadableOptions.modules;
+          return noSSR(loadableFn, loadableOptions);
+        }
+        return loadableFn({
+          ...loadableOptions,
+          loader: loader,
+        });
+      }
+      if (
+        (typeof exports.default === "function" ||
+          (typeof exports.default === "object" && exports.default !== null)) &&
+        typeof exports.default.__esModule === "undefined"
+      ) {
+        Object.defineProperty(exports.default, "__esModule", {
+          value: true,
+        });
+        Object.assign(exports.default, exports);
+        module.exports = exports.default;
+      } //# sourceMappingURL=dynamic.js.map
+
+      /***/
+    },
+
+    /***/ 7514: /***/ (
+      module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      module.exports = __webpack_require__(6828);
+
+      /***/
+    },
+
+    /***/ 8084: /***/ (
+      __unused_webpack_module,
+      __webpack_exports__,
+      __webpack_require__
+    ) => {
+      "use strict";
+      __webpack_require__.r(__webpack_exports__);
+      /* harmony export */ __webpack_require__.d(__webpack_exports__, {
+        /* harmony export */ __N_SSP: () => /* binding */ __N_SSP,
+        /* harmony export */ default: () => __WEBPACK_DEFAULT_EXPORT__,
+        /* harmony export */
+      });
+      /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
+        __webpack_require__(1503);
+      /* harmony import */ var next_dynamic__WEBPACK_IMPORTED_MODULE_1__ =
+        __webpack_require__(7514);
+      /* harmony import */ var next_dynamic__WEBPACK_IMPORTED_MODULE_1___default =
+        /*#__PURE__*/ __webpack_require__.n(
+          next_dynamic__WEBPACK_IMPORTED_MODULE_1__
+        );
+
+      const DynamicHello = next_dynamic__WEBPACK_IMPORTED_MODULE_1___default()(
+        () =>
+          __webpack_require__
+            .e(/* import() */ 9573)
+            .then(__webpack_require__.bind(__webpack_require__, 9573))
+            .then((mod) => mod.Hello),
+        {
+          loadableGenerated: {
+            webpack: () => [/*require.resolve*/ 9573],
+          },
+        }
+      );
+      const Page = () =>
+        /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(
+          react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment,
+          {
+            children: [
+              /*#__PURE__*/ (0,
+              react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p", {
+                children: "testing next/dynamic size",
+              }),
+              /*#__PURE__*/ (0,
+              react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(
+                DynamicHello,
+                {}
+              ),
+            ],
+          }
+        );
+      var __N_SSP = true;
+      /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = Page;
+
+      /***/
+    },
   },
   /******/ (__webpack_require__) => {
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(1033)
+      __webpack_exec__(431)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for edge-ssr-HASH.js
@@ -1,24 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [676],
   {
-    /***/ 1819: /***/ (
-      __unused_webpack_module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      (window.__NEXT_P = window.__NEXT_P || []).push([
-        "/edge-ssr",
-        function () {
-          return __webpack_require__(5142);
-        },
-      ]);
-      if (false) {
-      }
-
-      /***/
-    },
-
-    /***/ 5142: /***/ (
+    /***/ 983: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -37,13 +20,30 @@
 
       /***/
     },
+
+    /***/ 985: /***/ (
+      __unused_webpack_module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      (window.__NEXT_P = window.__NEXT_P || []).push([
+        "/edge-ssr",
+        function () {
+          return __webpack_require__(983);
+        },
+      ]);
+      if (false) {
+      }
+
+      /***/
+    },
   },
   /******/ (__webpack_require__) => {
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(1819)
+      __webpack_exec__(985)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for head-HASH.js
@@ -1,24 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [5350],
   {
-    /***/ 619: /***/ (
-      __unused_webpack_module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      (window.__NEXT_P = window.__NEXT_P || []).push([
-        "/head",
-        function () {
-          return __webpack_require__(3324);
-        },
-      ]);
-      if (false) {
-      }
-
-      /***/
-    },
-
-    /***/ 3324: /***/ (
+    /***/ 1417: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -33,7 +16,7 @@
       /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
         __webpack_require__(1503);
       /* harmony import */ var next_head__WEBPACK_IMPORTED_MODULE_1__ =
-        __webpack_require__(7997);
+        __webpack_require__(5171);
       /* harmony import */ var next_head__WEBPACK_IMPORTED_MODULE_1___default =
         /*#__PURE__*/ __webpack_require__.n(
           next_head__WEBPACK_IMPORTED_MODULE_1__
@@ -67,12 +50,29 @@
       /***/
     },
 
-    /***/ 7997: /***/ (
+    /***/ 1937: /***/ (
+      __unused_webpack_module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      (window.__NEXT_P = window.__NEXT_P || []).push([
+        "/head",
+        function () {
+          return __webpack_require__(1417);
+        },
+      ]);
+      if (false) {
+      }
+
+      /***/
+    },
+
+    /***/ 5171: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(1286);
+      module.exports = __webpack_require__(7505);
 
       /***/
     },
@@ -82,7 +82,7 @@
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(619)
+      __webpack_exec__(1937)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for hooks-HASH.js
@@ -1,24 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [9804],
   {
-    /***/ 1679: /***/ (
-      __unused_webpack_module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      (window.__NEXT_P = window.__NEXT_P || []).push([
-        "/hooks",
-        function () {
-          return __webpack_require__(9198);
-        },
-      ]);
-      if (false) {
-      }
-
-      /***/
-    },
-
-    /***/ 9198: /***/ (
+    /***/ 1598: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -76,13 +59,30 @@
 
       /***/
     },
+
+    /***/ 3925: /***/ (
+      __unused_webpack_module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      (window.__NEXT_P = window.__NEXT_P || []).push([
+        "/hooks",
+        function () {
+          return __webpack_require__(1598);
+        },
+      ]);
+      if (false) {
+      }
+
+      /***/
+    },
   },
   /******/ (__webpack_require__) => {
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(1679)
+      __webpack_exec__(3925)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for image-HASH.js

Diff too large to display

Diff for link-HASH.js
@@ -1,7 +1,319 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [4672],
   {
-    /***/ 1970: /***/ (__unused_webpack_module, exports) => {
+    /***/ 1511: /***/ (module, exports, __webpack_require__) => {
+      "use strict";
+
+      Object.defineProperty(exports, "__esModule", {
+        value: true,
+      });
+      Object.defineProperty(exports, "useMergedRef", {
+        enumerable: true,
+        get: function () {
+          return useMergedRef;
+        },
+      });
+      const _react = __webpack_require__(2223);
+      function useMergedRef(refA, refB) {
+        const cleanupA = (0, _react.useRef)(null);
+        const cleanupB = (0, _react.useRef)(null);
+        // NOTE: In theory, we could skip the wrapping if only one of the refs is non-null.
+        // (this happens often if the user doesn't pass a ref to Link/Form/Image)
+        // But this can cause us to leak a cleanup-ref into user code (previously via `<Link legacyBehavior>`),
+        // and the user might pass that ref into ref-merging library that doesn't support cleanup refs
+        // (because it hasn't been updated for React 19)
+        // which can then cause things to blow up, because a cleanup-returning ref gets called with `null`.
+        // So in practice, it's safer to be defensive and always wrap the ref, even on React 19.
+        return (0, _react.useCallback)(
+          (current) => {
+            if (current === null) {
+              const cleanupFnA = cleanupA.current;
+              if (cleanupFnA) {
+                cleanupA.current = null;
+                cleanupFnA();
+              }
+              const cleanupFnB = cleanupB.current;
+              if (cleanupFnB) {
+                cleanupB.current = null;
+                cleanupFnB();
+              }
+            } else {
+              if (refA) {
+                cleanupA.current = applyRef(refA, current);
+              }
+              if (refB) {
+                cleanupB.current = applyRef(refB, current);
+              }
+            }
+          },
+          [refA, refB]
+        );
+      }
+      function applyRef(refA, current) {
+        if (typeof refA === "function") {
+          const cleanup = refA(current);
+          if (typeof cleanup === "function") {
+            return cleanup;
+          } else {
+            return () => refA(null);
+          }
+        } else {
+          refA.current = current;
+          return () => {
+            refA.current = null;
+          };
+        }
+      }
+      if (
+        (typeof exports.default === "function" ||
+          (typeof exports.default === "object" && exports.default !== null)) &&
+        typeof exports.default.__esModule === "undefined"
+      ) {
+        Object.defineProperty(exports.default, "__esModule", {
+          value: true,
+        });
+        Object.assign(exports.default, exports);
+        module.exports = exports.default;
+      } //# sourceMappingURL=use-merged-ref.js.map
+
+      /***/
+    },
+
+    /***/ 2025: /***/ (
+      __unused_webpack_module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      (window.__NEXT_P = window.__NEXT_P || []).push([
+        "/link",
+        function () {
+          return __webpack_require__(4591);
+        },
+      ]);
+      if (false) {
+      }
+
+      /***/
+    },
+
+    /***/ 3267: /***/ (module, exports, __webpack_require__) => {
+      "use strict";
+
+      Object.defineProperty(exports, "__esModule", {
+        value: true,
+      });
+      Object.defineProperty(exports, "getDomainLocale", {
+        enumerable: true,
+        get: function () {
+          return getDomainLocale;
+        },
+      });
+      const _normalizetrailingslash = __webpack_require__(2371);
+      const basePath =
+        /* unused pure expression or super */ null && (false || "");
+      function getDomainLocale(path, locale, locales, domainLocales) {
+        if (false) {
+        } else {
+          return false;
+        }
+      }
+      if (
+        (typeof exports.default === "function" ||
+          (typeof exports.default === "object" && exports.default !== null)) &&
+        typeof exports.default.__esModule === "undefined"
+      ) {
+        Object.defineProperty(exports.default, "__esModule", {
+          value: true,
+        });
+        Object.assign(exports.default, exports);
+        module.exports = exports.default;
+      } //# sourceMappingURL=get-domain-locale.js.map
+
+      /***/
+    },
+
+    /***/ 4591: /***/ (
+      __unused_webpack_module,
+      __webpack_exports__,
+      __webpack_require__
+    ) => {
+      "use strict";
+      __webpack_require__.r(__webpack_exports__);
+      /* harmony export */ __webpack_require__.d(__webpack_exports__, {
+        /* harmony export */ __N_SSP: () => /* binding */ __N_SSP,
+        /* harmony export */ default: () => __WEBPACK_DEFAULT_EXPORT__,
+        /* harmony export */
+      });
+      /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
+        __webpack_require__(1503);
+      /* harmony import */ var next_link__WEBPACK_IMPORTED_MODULE_1__ =
+        __webpack_require__(6929);
+      /* harmony import */ var next_link__WEBPACK_IMPORTED_MODULE_1___default =
+        /*#__PURE__*/ __webpack_require__.n(
+          next_link__WEBPACK_IMPORTED_MODULE_1__
+        );
+
+      function aLink(props) {
+        return /*#__PURE__*/ (0,
+        react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
+          children: [
+            /*#__PURE__*/ (0,
+            react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h3", {
+              children: "A Link page!",
+            }),
+            /*#__PURE__*/ (0,
+            react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(
+              next_link__WEBPACK_IMPORTED_MODULE_1___default(),
+              {
+                href: "/",
+                children: "Go to /",
+              }
+            ),
+          ],
+        });
+      }
+      var __N_SSP = true;
+      /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = aLink;
+
+      /***/
+    },
+
+    /***/ 6929: /***/ (
+      module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      module.exports = __webpack_require__(8885);
+
+      /***/
+    },
+
+    /***/ 7686: /***/ (module, exports, __webpack_require__) => {
+      "use strict";
+
+      Object.defineProperty(exports, "__esModule", {
+        value: true,
+      });
+      Object.defineProperty(exports, "useIntersection", {
+        enumerable: true,
+        get: function () {
+          return useIntersection;
+        },
+      });
+      const _react = __webpack_require__(2223);
+      const _requestidlecallback = __webpack_require__(901);
+      const hasIntersectionObserver =
+        typeof IntersectionObserver === "function";
+      const observers = new Map();
+      const idList = [];
+      function createObserver(options) {
+        const id = {
+          root: options.root || null,
+          margin: options.rootMargin || "",
+        };
+        const existing = idList.find(
+          (obj) => obj.root === id.root && obj.margin === id.margin
+        );
+        let instance;
+        if (existing) {
+          instance = observers.get(existing);
+          if (instance) {
+            return instance;
+          }
+        }
+        const elements = new Map();
+        const observer = new IntersectionObserver((entries) => {
+          entries.forEach((entry) => {
+            const callback = elements.get(entry.target);
+            const isVisible =
+              entry.isIntersecting || entry.intersectionRatio > 0;
+            if (callback && isVisible) {
+              callback(isVisible);
+            }
+          });
+        }, options);
+        instance = {
+          id,
+          observer,
+          elements,
+        };
+        idList.push(id);
+        observers.set(id, instance);
+        return instance;
+      }
+      function observe(element, callback, options) {
+        const { id, observer, elements } = createObserver(options);
+        elements.set(element, callback);
+        observer.observe(element);
+        return function unobserve() {
+          elements.delete(element);
+          observer.unobserve(element);
+          // Destroy observer when there's nothing left to watch:
+          if (elements.size === 0) {
+            observer.disconnect();
+            observers.delete(id);
+            const index = idList.findIndex(
+              (obj) => obj.root === id.root && obj.margin === id.margin
+            );
+            if (index > -1) {
+              idList.splice(index, 1);
+            }
+          }
+        };
+      }
+      function useIntersection({ rootRef, rootMargin, disabled }) {
+        const isDisabled = disabled || !hasIntersectionObserver;
+        const [visible, setVisible] = (0, _react.useState)(false);
+        const elementRef = (0, _react.useRef)(null);
+        const setElement = (0, _react.useCallback)((element) => {
+          elementRef.current = element;
+        }, []);
+        (0, _react.useEffect)(() => {
+          if (hasIntersectionObserver) {
+            if (isDisabled || visible) return;
+            const element = elementRef.current;
+            if (element && element.tagName) {
+              const unobserve = observe(
+                element,
+                (isVisible) => isVisible && setVisible(isVisible),
+                {
+                  root: rootRef?.current,
+                  rootMargin,
+                }
+              );
+              return unobserve;
+            }
+          } else {
+            if (!visible) {
+              const idleCallback = (0,
+              _requestidlecallback.requestIdleCallback)(() => setVisible(true));
+              return () =>
+                (0, _requestidlecallback.cancelIdleCallback)(idleCallback);
+            }
+          }
+          // eslint-disable-next-line react-hooks/exhaustive-deps
+        }, [isDisabled, rootMargin, rootRef, visible, elementRef.current]);
+        const resetVisible = (0, _react.useCallback)(() => {
+          setVisible(false);
+        }, []);
+        return [setElement, visible, resetVisible];
+      }
+      if (
+        (typeof exports.default === "function" ||
+          (typeof exports.default === "object" && exports.default !== null)) &&
+        typeof exports.default.__esModule === "undefined"
+      ) {
+        Object.defineProperty(exports.default, "__esModule", {
+          value: true,
+        });
+        Object.assign(exports.default, exports);
+        module.exports = exports.default;
+      } //# sourceMappingURL=use-intersection.js.map
+
+      /***/
+    },
+
+    /***/ 8101: /***/ (__unused_webpack_module, exports) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -20,7 +332,7 @@
       /***/
     },
 
-    /***/ 3262: /***/ (module, exports, __webpack_require__) => {
+    /***/ 8885: /***/ (module, exports, __webpack_require__) => {
       "use strict";
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
@@ -47,17 +359,17 @@
       const _react = /*#__PURE__*/ _interop_require_wildcard._(
         __webpack_require__(2223)
       );
-      const _resolvehref = __webpack_require__(7868);
-      const _islocalurl = __webpack_require__(9350);
-      const _formaturl = __webpack_require__(6319);
-      const _utils = __webpack_require__(9889);
-      const _addlocale = __webpack_require__(9466);
-      const _routercontextsharedruntime = __webpack_require__(5691);
-      const _useintersection = __webpack_require__(3981);
-      const _getdomainlocale = __webpack_require__(4206);
-      const _addbasepath = __webpack_require__(9339);
-      const _usemergedref = __webpack_require__(6848);
-      const _erroronce = __webpack_require__(1970);
+      const _resolvehref = __webpack_require__(7379);
+      const _islocalurl = __webpack_require__(4843);
+      const _formaturl = __webpack_require__(9374);
+      const _utils = __webpack_require__(3116);
+      const _addlocale = __webpack_require__(8065);
+      const _routercontextsharedruntime = __webpack_require__(5470);
+      const _useintersection = __webpack_require__(7686);
+      const _getdomainlocale = __webpack_require__(3267);
+      const _addbasepath = __webpack_require__(1450);
+      const _usemergedref = __webpack_require__(1511);
+      const _erroronce = __webpack_require__(8101);
       const prefetched = new Set();
       function prefetch(router, href, as, options) {
         if (false) {
@@ -435,325 +747,13 @@
 
       /***/
     },
-
-    /***/ 3981: /***/ (module, exports, __webpack_require__) => {
-      "use strict";
-
-      Object.defineProperty(exports, "__esModule", {
-        value: true,
-      });
-      Object.defineProperty(exports, "useIntersection", {
-        enumerable: true,
-        get: function () {
-          return useIntersection;
-        },
-      });
-      const _react = __webpack_require__(2223);
-      const _requestidlecallback = __webpack_require__(1472);
-      const hasIntersectionObserver =
-        typeof IntersectionObserver === "function";
-      const observers = new Map();
-      const idList = [];
-      function createObserver(options) {
-        const id = {
-          root: options.root || null,
-          margin: options.rootMargin || "",
-        };
-        const existing = idList.find(
-          (obj) => obj.root === id.root && obj.margin === id.margin
-        );
-        let instance;
-        if (existing) {
-          instance = observers.get(existing);
-          if (instance) {
-            return instance;
-          }
-        }
-        const elements = new Map();
-        const observer = new IntersectionObserver((entries) => {
-          entries.forEach((entry) => {
-            const callback = elements.get(entry.target);
-            const isVisible =
-              entry.isIntersecting || entry.intersectionRatio > 0;
-            if (callback && isVisible) {
-              callback(isVisible);
-            }
-          });
-        }, options);
-        instance = {
-          id,
-          observer,
-          elements,
-        };
-        idList.push(id);
-        observers.set(id, instance);
-        return instance;
-      }
-      function observe(element, callback, options) {
-        const { id, observer, elements } = createObserver(options);
-        elements.set(element, callback);
-        observer.observe(element);
-        return function unobserve() {
-          elements.delete(element);
-          observer.unobserve(element);
-          // Destroy observer when there's nothing left to watch:
-          if (elements.size === 0) {
-            observer.disconnect();
-            observers.delete(id);
-            const index = idList.findIndex(
-              (obj) => obj.root === id.root && obj.margin === id.margin
-            );
-            if (index > -1) {
-              idList.splice(index, 1);
-            }
-          }
-        };
-      }
-      function useIntersection({ rootRef, rootMargin, disabled }) {
-        const isDisabled = disabled || !hasIntersectionObserver;
-        const [visible, setVisible] = (0, _react.useState)(false);
-        const elementRef = (0, _react.useRef)(null);
-        const setElement = (0, _react.useCallback)((element) => {
-          elementRef.current = element;
-        }, []);
-        (0, _react.useEffect)(() => {
-          if (hasIntersectionObserver) {
-            if (isDisabled || visible) return;
-            const element = elementRef.current;
-            if (element && element.tagName) {
-              const unobserve = observe(
-                element,
-                (isVisible) => isVisible && setVisible(isVisible),
-                {
-                  root: rootRef?.current,
-                  rootMargin,
-                }
-              );
-              return unobserve;
-            }
-          } else {
-            if (!visible) {
-              const idleCallback = (0,
-              _requestidlecallback.requestIdleCallback)(() => setVisible(true));
-              return () =>
-                (0, _requestidlecallback.cancelIdleCallback)(idleCallback);
-            }
-          }
-          // eslint-disable-next-line react-hooks/exhaustive-deps
-        }, [isDisabled, rootMargin, rootRef, visible, elementRef.current]);
-        const resetVisible = (0, _react.useCallback)(() => {
-          setVisible(false);
-        }, []);
-        return [setElement, visible, resetVisible];
-      }
-      if (
-        (typeof exports.default === "function" ||
-          (typeof exports.default === "object" && exports.default !== null)) &&
-        typeof exports.default.__esModule === "undefined"
-      ) {
-        Object.defineProperty(exports.default, "__esModule", {
-          value: true,
-        });
-        Object.assign(exports.default, exports);
-        module.exports = exports.default;
-      } //# sourceMappingURL=use-intersection.js.map
-
-      /***/
-    },
-
-    /***/ 4206: /***/ (module, exports, __webpack_require__) => {
-      "use strict";
-
-      Object.defineProperty(exports, "__esModule", {
-        value: true,
-      });
-      Object.defineProperty(exports, "getDomainLocale", {
-        enumerable: true,
-        get: function () {
-          return getDomainLocale;
-        },
-      });
-      const _normalizetrailingslash = __webpack_require__(6704);
-      const basePath =
-        /* unused pure expression or super */ null && (false || "");
-      function getDomainLocale(path, locale, locales, domainLocales) {
-        if (false) {
-        } else {
-          return false;
-        }
-      }
-      if (
-        (typeof exports.default === "function" ||
-          (typeof exports.default === "object" && exports.default !== null)) &&
-        typeof exports.default.__esModule === "undefined"
-      ) {
-        Object.defineProperty(exports.default, "__esModule", {
-          value: true,
-        });
-        Object.assign(exports.default, exports);
-        module.exports = exports.default;
-      } //# sourceMappingURL=get-domain-locale.js.map
-
-      /***/
-    },
-
-    /***/ 6691: /***/ (
-      module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      module.exports = __webpack_require__(3262);
-
-      /***/
-    },
-
-    /***/ 6771: /***/ (
-      __unused_webpack_module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      (window.__NEXT_P = window.__NEXT_P || []).push([
-        "/link",
-        function () {
-          return __webpack_require__(8178);
-        },
-      ]);
-      if (false) {
-      }
-
-      /***/
-    },
-
-    /***/ 6848: /***/ (module, exports, __webpack_require__) => {
-      "use strict";
-
-      Object.defineProperty(exports, "__esModule", {
-        value: true,
-      });
-      Object.defineProperty(exports, "useMergedRef", {
-        enumerable: true,
-        get: function () {
-          return useMergedRef;
-        },
-      });
-      const _react = __webpack_require__(2223);
-      function useMergedRef(refA, refB) {
-        const cleanupA = (0, _react.useRef)(null);
-        const cleanupB = (0, _react.useRef)(null);
-        // NOTE: In theory, we could skip the wrapping if only one of the refs is non-null.
-        // (this happens often if the user doesn't pass a ref to Link/Form/Image)
-        // But this can cause us to leak a cleanup-ref into user code (previously via `<Link legacyBehavior>`),
-        // and the user might pass that ref into ref-merging library that doesn't support cleanup refs
-        // (because it hasn't been updated for React 19)
-        // which can then cause things to blow up, because a cleanup-returning ref gets called with `null`.
-        // So in practice, it's safer to be defensive and always wrap the ref, even on React 19.
-        return (0, _react.useCallback)(
-          (current) => {
-            if (current === null) {
-              const cleanupFnA = cleanupA.current;
-              if (cleanupFnA) {
-                cleanupA.current = null;
-                cleanupFnA();
-              }
-              const cleanupFnB = cleanupB.current;
-              if (cleanupFnB) {
-                cleanupB.current = null;
-                cleanupFnB();
-              }
-            } else {
-              if (refA) {
-                cleanupA.current = applyRef(refA, current);
-              }
-              if (refB) {
-                cleanupB.current = applyRef(refB, current);
-              }
-            }
-          },
-          [refA, refB]
-        );
-      }
-      function applyRef(refA, current) {
-        if (typeof refA === "function") {
-          const cleanup = refA(current);
-          if (typeof cleanup === "function") {
-            return cleanup;
-          } else {
-            return () => refA(null);
-          }
-        } else {
-          refA.current = current;
-          return () => {
-            refA.current = null;
-          };
-        }
-      }
-      if (
-        (typeof exports.default === "function" ||
-          (typeof exports.default === "object" && exports.default !== null)) &&
-        typeof exports.default.__esModule === "undefined"
-      ) {
-        Object.defineProperty(exports.default, "__esModule", {
-          value: true,
-        });
-        Object.assign(exports.default, exports);
-        module.exports = exports.default;
-      } //# sourceMappingURL=use-merged-ref.js.map
-
-      /***/
-    },
-
-    /***/ 8178: /***/ (
-      __unused_webpack_module,
-      __webpack_exports__,
-      __webpack_require__
-    ) => {
-      "use strict";
-      __webpack_require__.r(__webpack_exports__);
-      /* harmony export */ __webpack_require__.d(__webpack_exports__, {
-        /* harmony export */ __N_SSP: () => /* binding */ __N_SSP,
-        /* harmony export */ default: () => __WEBPACK_DEFAULT_EXPORT__,
-        /* harmony export */
-      });
-      /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
-        __webpack_require__(1503);
-      /* harmony import */ var next_link__WEBPACK_IMPORTED_MODULE_1__ =
-        __webpack_require__(6691);
-      /* harmony import */ var next_link__WEBPACK_IMPORTED_MODULE_1___default =
-        /*#__PURE__*/ __webpack_require__.n(
-          next_link__WEBPACK_IMPORTED_MODULE_1__
-        );
-
-      function aLink(props) {
-        return /*#__PURE__*/ (0,
-        react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
-          children: [
-            /*#__PURE__*/ (0,
-            react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h3", {
-              children: "A Link page!",
-            }),
-            /*#__PURE__*/ (0,
-            react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(
-              next_link__WEBPACK_IMPORTED_MODULE_1___default(),
-              {
-                href: "/",
-                children: "Go to /",
-              }
-            ),
-          ],
-        });
-      }
-      var __N_SSP = true;
-      /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = aLink;
-
-      /***/
-    },
   },
   /******/ (__webpack_require__) => {
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(6771)
+      __webpack_exec__(2025)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for routerDirect-HASH.js
@@ -1,7 +1,34 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [188],
   {
-    /***/ 286: /***/ (
+    /***/ 417: /***/ (
+      __unused_webpack_module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      (window.__NEXT_P = window.__NEXT_P || []).push([
+        "/routerDirect",
+        function () {
+          return __webpack_require__(5491);
+        },
+      ]);
+      if (false) {
+      }
+
+      /***/
+    },
+
+    /***/ 1840: /***/ (
+      module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      module.exports = __webpack_require__(3252);
+
+      /***/
+    },
+
+    /***/ 5491: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -16,7 +43,7 @@
       /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
         __webpack_require__(1503);
       /* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_1__ =
-        __webpack_require__(7798);
+        __webpack_require__(1840);
       /* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_1___default =
         /*#__PURE__*/ __webpack_require__.n(
           next_router__WEBPACK_IMPORTED_MODULE_1__
@@ -35,40 +62,13 @@
 
       /***/
     },
-
-    /***/ 4283: /***/ (
-      __unused_webpack_module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      (window.__NEXT_P = window.__NEXT_P || []).push([
-        "/routerDirect",
-        function () {
-          return __webpack_require__(286);
-        },
-      ]);
-      if (false) {
-      }
-
-      /***/
-    },
-
-    /***/ 7798: /***/ (
-      module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      module.exports = __webpack_require__(9587);
-
-      /***/
-    },
   },
   /******/ (__webpack_require__) => {
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(4283)
+      __webpack_exec__(417)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for withRouter-HASH.js
@@ -1,24 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [3263],
   {
-    /***/ 3163: /***/ (
-      __unused_webpack_module,
-      __unused_webpack_exports,
-      __webpack_require__
-    ) => {
-      (window.__NEXT_P = window.__NEXT_P || []).push([
-        "/withRouter",
-        function () {
-          return __webpack_require__(3295);
-        },
-      ]);
-      if (false) {
-      }
-
-      /***/
-    },
-
-    /***/ 3295: /***/ (
+    /***/ 358: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -33,7 +16,7 @@
       /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ =
         __webpack_require__(1503);
       /* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_1__ =
-        __webpack_require__(7798);
+        __webpack_require__(1840);
       /* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_1___default =
         /*#__PURE__*/ __webpack_require__.n(
           next_router__WEBPACK_IMPORTED_MODULE_1__
@@ -52,12 +35,29 @@
       /***/
     },
 
-    /***/ 7798: /***/ (
+    /***/ 1840: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(9587);
+      module.exports = __webpack_require__(3252);
+
+      /***/
+    },
+
+    /***/ 4041: /***/ (
+      __unused_webpack_module,
+      __unused_webpack_exports,
+      __webpack_require__
+    ) => {
+      (window.__NEXT_P = window.__NEXT_P || []).push([
+        "/withRouter",
+        function () {
+          return __webpack_require__(358);
+        },
+      ]);
+      if (false) {
+      }
 
       /***/
     },
@@ -67,7 +67,7 @@
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [636, 6593, 8792], () =>
-      __webpack_exec__(3163)
+      __webpack_exec__(4041)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for 4498-HASH.js
failed to diff
Diff for 9225-HASH.js

Diff too large to display

Diff for main-HASH.js

Diff too large to display

Commit: 2718ee4

@gnoff gnoff force-pushed the refine-next-js-condition branch 2 times, most recently from a46c992 to 297acd6 Compare October 24, 2025 20:57
Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments:

test/lib/next-modes/base.ts (lines 159-169):
The code that removes existing files/symlinks before copying doesn't handle directories, which could cause the copy operation to fail if a directory already exists at the target path.

View Details
📝 Patch Details
diff --git a/test/lib/next-modes/base.ts b/test/lib/next-modes/base.ts
index c8de248b1e..b5e5e3c857 100644
--- a/test/lib/next-modes/base.ts
+++ b/test/lib/next-modes/base.ts
@@ -157,12 +157,11 @@ export class NextInstance {
           await fs.writeFile(outputFilename, item)
         } else {
           try {
-            const existingStat = await fs.lstat(outputFilename)
-            if (existingStat.isFile() || existingStat.isSymbolicLink()) {
-              await fs.unlink(outputFilename)
-            }
+            // Remove any existing file, symlink, or directory at this path
+            // to ensure the copy operation doesn't merge with existing content
+            await fs.rm(outputFilename, { recursive: true, force: true })
           } catch {
-            // file might not exist or can't be unliked. carry on
+            // path might not exist or can't be deleted. carry on
           }
 
           await fs.cp(item.fsPath, outputFilename, { recursive: true })

Analysis

Missing directory deletion in writeFiles() causes improper merge behavior during file overrides

What fails: The writeFiles() method in test/lib/next-modes/base.ts only removes files and symlinks before copying FileRef objects, but does not remove existing directories. This causes fs.cp() to merge the source directory contents with any existing directory at the target path instead of replacing it entirely.

How to reproduce:

  1. Setup initial test files that create a directory at path app/
  2. Call writeOverrideFiles() with a FileRef pointing to a different directory
  3. The result is a merged directory containing both old and new files instead of a clean replacement

Result: When copying a directory to a location where a directory already exists, the contents merge rather than replace:

Initial: app/ contains [ 'layout.ts', 'utils/' ]
Override: app/ set to new source directory containing [ 'page.ts' ]
Actual result: app/ contains [ 'layout.ts', 'utils/', 'page.ts' ] (MERGED)
Expected result: app/ contains [ 'page.ts' ] (REPLACED)

Expected behavior: The method is named writeOverrideFiles() which semantically indicates files should be replaced. Currently handles symlinks and files correctly by deleting them first, but directories are left in place causing fs.cp with recursive: true to merge instead of replace (per Node.js fs.cp documentation).

Fixed by: Replacing the conditional file/symlink deletion with fs.rm(outputFilename, { recursive: true, force: true }) to handle all types (files, symlinks, and directories) consistently before the copy operation.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 24, 2025

CodSpeed Performance Report

Merging #85321 will not alter performance

Comparing gnoff:refine-next-js-condition (2718ee4) with canary (8cdd4ea)

Summary

✅ 8 untouched
⏩ 12 skipped1

Footnotes

  1. 12 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@gnoff gnoff force-pushed the refine-next-js-condition branch 2 times, most recently from ebdfa73 to ce63a2c Compare October 27, 2025 15:44
These scopes aren't fully Next.js environments and can't access many Next.js APIs. In the future this might change but for now we will exclude the `next-js` condition when bundling for these entrypoints so that 3rd parties that target Next.js can do so with the expectation that regardless of what environment they are running in the full suite of Next.js libraries they support will work.
@gnoff gnoff force-pushed the refine-next-js-condition branch from ce63a2c to 2718ee4 Compare October 27, 2025 16:38
@gnoff gnoff merged commit 1b45163 into vercel:canary Oct 27, 2025
397 of 408 checks passed
@gnoff gnoff deleted the refine-next-js-condition branch October 27, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Next.js team PRs by the Next.js team. tests Turbopack Related to Turbopack with Next.js. type: next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants