Skip to content

feat: added rewrite headers after user-supplied rewrites#74776

Merged
wyattjoh merged 3 commits intocanaryfrom
feat/rewrite-headers
Jan 13, 2025
Merged

feat: added rewrite headers after user-supplied rewrites#74776
wyattjoh merged 3 commits intocanaryfrom
feat/rewrite-headers

Conversation

@wyattjoh
Copy link
Copy Markdown
Contributor

@wyattjoh wyattjoh commented Jan 10, 2025

Next.js's client router needs to know the pathname and query that the request was rewritten to in order to facilitate reuse of static RSC payloads generated from fallbacks. This takes the form of additional headers being sent back on the response that includes the correct rewritten pathname that later the client can take into account when generating the client route key.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ijjk
Copy link
Copy Markdown
Member

ijjk commented Jan 10, 2025

Stats from current PR

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary vercel/next.js feat/rewrite-headers Change
buildDuration 31.6s 32s ⚠️ +409ms
buildDurationCached 27.6s 23s N/A
nodeModulesSize 417 MB 417 MB N/A
nextStartRea..uration (ms) 776ms 931ms ⚠️ +155ms
Client Bundles (main, webpack) Overall increase ⚠️
vercel/next.js canary vercel/next.js feat/rewrite-headers Change
5306-HASH.js gzip 53.3 kB 53.4 kB N/A
8276.HASH.js gzip 169 B 168 B N/A
8377-HASH.js gzip 5.44 kB 5.44 kB N/A
bccd1874-HASH.js gzip 52.9 kB 53 kB ⚠️ +104 B
framework-HASH.js gzip 57.5 kB 57.5 kB N/A
main-app-HASH.js gzip 240 B 241 B N/A
main-HASH.js gzip 34.2 kB 34.2 kB N/A
webpack-HASH.js gzip 1.71 kB 1.71 kB N/A
Overall change 52.9 kB 53 kB ⚠️ +104 B
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js feat/rewrite-headers 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 vercel/next.js feat/rewrite-headers Change
_app-HASH.js gzip 193 B 193 B
_error-HASH.js gzip 193 B 193 B
amp-HASH.js gzip 512 B 510 B N/A
css-HASH.js gzip 343 B 342 B N/A
dynamic-HASH.js gzip 1.84 kB 1.84 kB
edge-ssr-HASH.js gzip 265 B 265 B
head-HASH.js gzip 363 B 362 B N/A
hooks-HASH.js gzip 393 B 392 B N/A
image-HASH.js gzip 4.57 kB 4.57 kB N/A
index-HASH.js gzip 268 B 268 B
link-HASH.js gzip 2.35 kB 2.34 kB N/A
routerDirect..HASH.js gzip 328 B 328 B
script-HASH.js gzip 397 B 397 B
withRouter-HASH.js gzip 323 B 326 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 3.59 kB 3.59 kB
Client Build Manifests
vercel/next.js canary vercel/next.js feat/rewrite-headers Change
_buildManifest.js gzip 749 B 747 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js feat/rewrite-headers Change
index.html gzip 524 B 524 B
link.html gzip 539 B 538 B N/A
withRouter.html gzip 520 B 520 B
Overall change 1.04 kB 1.04 kB
Edge SSR bundle Size
vercel/next.js canary vercel/next.js feat/rewrite-headers Change
edge-ssr.js gzip 129 kB 129 kB N/A
page.js gzip 207 kB 207 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js feat/rewrite-headers Change
middleware-b..fest.js gzip 671 B 669 B N/A
middleware-r..fest.js gzip 155 B 156 B N/A
middleware.js gzip 31.2 kB 31.2 kB N/A
edge-runtime..pack.js gzip 844 B 844 B
Overall change 844 B 844 B
Next Runtimes
vercel/next.js canary vercel/next.js feat/rewrite-headers Change
274-experime...dev.js gzip 322 B 322 B
274.runtime.dev.js gzip 314 B 314 B
app-page-exp...dev.js gzip 369 kB 369 kB N/A
app-page-exp..prod.js gzip 130 kB 130 kB N/A
app-page-tur..prod.js gzip 142 kB 142 kB N/A
app-page-tur..prod.js gzip 138 kB 138 kB N/A
app-page.run...dev.js gzip 357 kB 357 kB N/A
app-page.run..prod.js gzip 126 kB 126 kB N/A
app-route-ex...dev.js gzip 37.6 kB 37.6 kB N/A
app-route-ex..prod.js gzip 25.6 kB 25.6 kB N/A
app-route-tu..prod.js gzip 25.6 kB 25.6 kB N/A
app-route-tu..prod.js gzip 25.4 kB 25.4 kB N/A
app-route.ru...dev.js gzip 39.2 kB 39.2 kB N/A
app-route.ru..prod.js gzip 25.4 kB 25.4 kB N/A
pages-api-tu..prod.js gzip 9.69 kB 9.69 kB
pages-api.ru...dev.js gzip 11.6 kB 11.6 kB
pages-api.ru..prod.js gzip 9.68 kB 9.68 kB
pages-turbo...prod.js gzip 21.7 kB 21.7 kB
pages.runtim...dev.js gzip 27.5 kB 27.5 kB
pages.runtim..prod.js gzip 21.7 kB 21.7 kB
server.runti..prod.js gzip 916 kB 916 kB N/A
Overall change 103 kB 103 kB
build cache Overall increase ⚠️
vercel/next.js canary vercel/next.js feat/rewrite-headers Change
0.pack gzip 2.09 MB 2.09 MB N/A
index.pack gzip 74.5 kB 75.1 kB ⚠️ +610 B
Overall change 74.5 kB 75.1 kB ⚠️ +610 B
Diff details
Diff for middleware.js

Diff too large to display

Diff for edge-ssr.js

Diff too large to display

Diff for 5306-HASH.js

Diff too large to display

Diff for bccd1874-HASH.js
@@ -1,13 +1,13 @@
 "use strict";
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
-  [7629],
+  [1758],
   {
-    /***/ 641: /***/ (
+    /***/ 8699: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
     ) => {
-      /* provided dependency */ var process = __webpack_require__(6611);
+      /* provided dependency */ var process = __webpack_require__(9829);
       /**
        * @license React
        * react-dom-client.production.js
@@ -22,9 +22,9 @@
  Modernizr 3.0.0pre (Custom Build) | MIT
 */
 
-      var Scheduler = __webpack_require__(8684),
-        React = __webpack_require__(1446),
-        ReactDOM = __webpack_require__(8307);
+      var Scheduler = __webpack_require__(462),
+        React = __webpack_require__(228),
+        ReactDOM = __webpack_require__(9221);
       function formatProdErrorMessage(code) {
         var url = "https://react.dev/errors/" + code;
         if (1 < arguments.length) {
@@ -2086,14 +2086,14 @@
       if (canUseDOM) {
         var JSCompiler_inline_result$jscomp$279;
         if (canUseDOM) {
-          var isSupported$jscomp$inline_414 = "oninput" in document;
-          if (!isSupported$jscomp$inline_414) {
-            var element$jscomp$inline_415 = document.createElement("div");
-            element$jscomp$inline_415.setAttribute("oninput", "return;");
-            isSupported$jscomp$inline_414 =
-              "function" === typeof element$jscomp$inline_415.oninput;
+          var isSupported$jscomp$inline_410 = "oninput" in document;
+          if (!isSupported$jscomp$inline_410) {
+            var element$jscomp$inline_411 = document.createElement("div");
+            element$jscomp$inline_411.setAttribute("oninput", "return;");
+            isSupported$jscomp$inline_410 =
+              "function" === typeof element$jscomp$inline_411.oninput;
           }
-          JSCompiler_inline_result$jscomp$279 = isSupported$jscomp$inline_414;
+          JSCompiler_inline_result$jscomp$279 = isSupported$jscomp$inline_410;
         } else JSCompiler_inline_result$jscomp$279 = !1;
         isInputEventSupported =
           JSCompiler_inline_result$jscomp$279 &&
@@ -2361,25 +2361,6 @@
         topLevelEventsToReactNames.set(domEventName, reactName);
         registerTwoPhaseEvent(reactName, [domEventName]);
       }
-      var CapturedStacks = new WeakMap();
-      function createCapturedValueAtFiber(value, source) {
-        if ("object" === typeof value && null !== value) {
-          var existing = CapturedStacks.get(value);
-          if (void 0 !== existing) return existing;
-          source = {
-            value: value,
-            source: source,
-            stack: getStackByFiberInDevAndProd(source),
-          };
-          CapturedStacks.set(value, source);
-          return source;
-        }
-        return {
-          value: value,
-          source: source,
-          stack: getStackByFiberInDevAndProd(source),
-        };
-      }
       var concurrentQueues = [],
         concurrentQueuesIndex = 0,
         concurrentlyUpdatedLanes = 0;
@@ -3007,6 +2988,265 @@
             cache.controller.abort();
           });
       }
+      var CapturedStacks = new WeakMap();
+      function createCapturedValueAtFiber(value, source) {
+        if ("object" === typeof value && null !== value) {
+          var existing = CapturedStacks.get(value);
+          if (void 0 !== existing) return existing;
+          source = {
+            value: value,
+            source: source,
+            stack: getStackByFiberInDevAndProd(source),
+          };
+          CapturedStacks.set(value, source);
+          return source;
+        }
+        return {
+          value: value,
+          source: source,
+          stack: getStackByFiberInDevAndProd(source),
+        };
+      }
+      var forkStack = [],
+        forkStackIndex = 0,
+        treeForkProvider = null,
+        treeForkCount = 0,
+        idStack = [],
+        idStackIndex = 0,
+        treeContextProvider = null,
+        treeContextId = 1,
+        treeContextOverflow = "";
+      function pushTreeFork(workInProgress, totalChildren) {
+        forkStack[forkStackIndex++] = treeForkCount;
+        forkStack[forkStackIndex++] = treeForkProvider;
+        treeForkProvider = workInProgress;
+        treeForkCount = totalChildren;
+      }
+      function pushTreeId(workInProgress, totalChildren, index) {
+        idStack[idStackIndex++] = treeContextId;
+        idStack[idStackIndex++] = treeContextOverflow;
+        idStack[idStackIndex++] = treeContextProvider;
+        treeContextProvider = workInProgress;
+        var baseIdWithLeadingBit = treeContextId;
+        workInProgress = treeContextOverflow;
+        var baseLength = 32 - clz32(baseIdWithLeadingBit) - 1;
+        baseIdWithLeadingBit &= ~(1 << baseLength);
+        index += 1;
+        var length = 32 - clz32(totalChildren) + baseLength;
+        if (30 < length) {
+          var numberOfOverflowBits = baseLength - (baseLength % 5);
+          length = (
+            baseIdWithLeadingBit &
+            ((1 << numberOfOverflowBits) - 1)
+          ).toString(32);
+          baseIdWithLeadingBit >>= numberOfOverflowBits;
+          baseLength -= numberOfOverflowBits;
+          treeContextId =
+            (1 << (32 - clz32(totalChildren) + baseLength)) |
+            (index << baseLength) |
+            baseIdWithLeadingBit;
+          treeContextOverflow = length + workInProgress;
+        } else
+          (treeContextId =
+            (1 << length) | (index << baseLength) | baseIdWithLeadingBit),
+            (treeContextOverflow = workInProgress);
+      }
+      function pushMaterializedTreeId(workInProgress) {
+        null !== workInProgress.return &&
+          (pushTreeFork(workInProgress, 1), pushTreeId(workInProgress, 1, 0));
+      }
+      function popTreeContext(workInProgress) {
+        for (; workInProgress === treeForkProvider; )
+          (treeForkProvider = forkStack[--forkStackIndex]),
+            (forkStack[forkStackIndex] = null),
+            (treeForkCount = forkStack[--forkStackIndex]),
+            (forkStack[forkStackIndex] = null);
+        for (; workInProgress === treeContextProvider; )
+          (treeContextProvider = idStack[--idStackIndex]),
+            (idStack[idStackIndex] = null),
+            (treeContextOverflow = idStack[--idStackIndex]),
+            (idStack[idStackIndex] = null),
+            (treeContextId = idStack[--idStackIndex]),
+            (idStack[idStackIndex] = null);
+      }
+      var hydrationParentFiber = null,
+        nextHydratableInstance = null,
+        isHydrating = !1,
+        hydrationErrors = null,
+        rootOrSingletonContext = !1,
+        HydrationMismatchException = Error(formatProdErrorMessage(519));
+      function throwOnHydrationMismatch(fiber) {
+        var error = Error(formatProdErrorMessage(418, ""));
+        queueHydrationError(createCapturedValueAtFiber(error, fiber));
+        throw HydrationMismatchException;
+      }
+      function prepareToHydrateHostInstance(fiber) {
+        var instance = fiber.stateNode,
+          type = fiber.type,
+          props = fiber.memoizedProps;
+        instance[internalInstanceKey] = fiber;
+        instance[internalPropsKey] = props;
+        switch (type) {
+          case "dialog":
+            listenToNonDelegatedEvent("cancel", instance);
+            listenToNonDelegatedEvent("close", instance);
+            break;
+          case "iframe":
+          case "object":
+          case "embed":
+            listenToNonDelegatedEvent("load", instance);
+            break;
+          case "video":
+          case "audio":
+            for (type = 0; type < mediaEventTypes.length; type++)
+              listenToNonDelegatedEvent(mediaEventTypes[type], instance);
+            break;
+          case "source":
+            listenToNonDelegatedEvent("error", instance);
+            break;
+          case "img":
+          case "image":
+          case "link":
+            listenToNonDelegatedEvent("error", instance);
+            listenToNonDelegatedEvent("load", instance);
+            break;
+          case "details":
+            listenToNonDelegatedEvent("toggle", instance);
+            break;
+          case "input":
+            listenToNonDelegatedEvent("invalid", instance);
+            initInput(
+              instance,
+              props.value,
+              props.defaultValue,
+              props.checked,
+              props.defaultChecked,
+              props.type,
+              props.name,
+              !0
+            );
+            track(instance);
+            break;
+          case "select":
+            listenToNonDelegatedEvent("invalid", instance);
+            break;
+          case "textarea":
+            listenToNonDelegatedEvent("invalid", instance),
+              initTextarea(
+                instance,
+                props.value,
+                props.defaultValue,
+                props.children
+              ),
+              track(instance);
+        }
+        type = props.children;
+        ("string" !== typeof type &&
+          "number" !== typeof type &&
+          "bigint" !== typeof type) ||
+        instance.textContent === "" + type ||
+        !0 === props.suppressHydrationWarning ||
+        checkForUnmatchedText(instance.textContent, type)
+          ? (null != props.popover &&
+              (listenToNonDelegatedEvent("beforetoggle", instance),
+              listenToNonDelegatedEvent("toggle", instance)),
+            null != props.onScroll &&
+              listenToNonDelegatedEvent("scroll", instance),
+            null != props.onScrollEnd &&
+              listenToNonDelegatedEvent("scrollend", instance),
+            null != props.onClick && (instance.onclick = noop$1),
+            (instance = !0))
+          : (instance = !1);
+        instance || throwOnHydrationMismatch(fiber);
+      }
+      function popToNextHostParent(fiber) {
+        for (hydrationParentFiber = fiber.return; hydrationParentFiber; )
+          switch (hydrationParentFiber.tag) {
+            case 3:
+            case 27:
+              rootOrSingletonContext = !0;
+              return;
+            case 5:
+            case 13:
+              rootOrSingletonContext = !1;
+              return;
+            default:
+              hydrationParentFiber = hydrationParentFiber.return;
+          }
+      }
+      function popHydrationState(fiber) {
+        if (fiber !== hydrationParentFiber) return !1;
+        if (!isHydrating)
+          return popToNextHostParent(fiber), (isHydrating = !0), !1;
+        var shouldClear = !1,
+          JSCompiler_temp;
+        if ((JSCompiler_temp = 3 !== fiber.tag && 27 !== fiber.tag)) {
+          if ((JSCompiler_temp = 5 === fiber.tag))
+            (JSCompiler_temp = fiber.type),
+              (JSCompiler_temp =
+                !("form" !== JSCompiler_temp && "button" !== JSCompiler_temp) ||
+                shouldSetTextContent(fiber.type, fiber.memoizedProps));
+          JSCompiler_temp = !JSCompiler_temp;
+        }
+        JSCompiler_temp && (shouldClear = !0);
+        shouldClear &&
+          nextHydratableInstance &&
+          throwOnHydrationMismatch(fiber);
+        popToNextHostParent(fiber);
+        if (13 === fiber.tag) {
+          fiber = fiber.memoizedState;
+          fiber = null !== fiber ? fiber.dehydrated : null;
+          if (!fiber) throw Error(formatProdErrorMessage(317));
+          a: {
+            fiber = fiber.nextSibling;
+            for (shouldClear = 0; fiber; ) {
+              if (8 === fiber.nodeType)
+                if (
+                  ((JSCompiler_temp = fiber.data), "/$" === JSCompiler_temp)
+                ) {
+                  if (0 === shouldClear) {
+                    nextHydratableInstance = getNextHydratable(
+                      fiber.nextSibling
+                    );
+                    break a;
+                  }
+                  shouldClear--;
+                } else
+                  ("$" !== JSCompiler_temp &&
+                    "$!" !== JSCompiler_temp &&
+                    "$?" !== JSCompiler_temp) ||
+                    shouldClear++;
+              fiber = fiber.nextSibling;
+            }
+            nextHydratableInstance = null;
+          }
+        } else
+          nextHydratableInstance = hydrationParentFiber
+            ? getNextHydratable(fiber.stateNode.nextSibling)
+            : null;
+        return !0;
+      }
+      function resetHydrationState() {
+        nextHydratableInstance = hydrationParentFiber = null;
+        isHydrating = !1;
+      }
+      function upgradeHydrationErrorsToRecoverable() {
+        var queuedErrors = hydrationErrors;
+        null !== queuedErrors &&
+          (null === workInProgressRootRecoverableErrors
+            ? (workInProgressRootRecoverableErrors = queuedErrors)
+            : workInProgressRootRecoverableErrors.push.apply(
+                workInProgressRootRecoverableErrors,
+                queuedErrors
+              ),
+          (hydrationErrors = null));
+        return queuedErrors;
+      }
+      function queueHydrationError(error) {
+        null === hydrationErrors
+          ? (hydrationErrors = [error])
+          : hydrationErrors.push(error);
+      }
       function applyDerivedStateFromProps(
         workInProgress,
         ctor,
@@ -3114,74 +3354,12 @@
         }
         if ((Component = Component.defaultProps)) {
           newProps === baseProps && (newProps = assign({}, newProps));
-          for (var propName$28 in Component)
-            void 0 === newProps[propName$28] &&
-              (newProps[propName$28] = Component[propName$28]);
+          for (var propName$30 in Component)
+            void 0 === newProps[propName$30] &&
+              (newProps[propName$30] = Component[propName$30]);
         }
         return newProps;
       }
-      var forkStack = [],
-        forkStackIndex = 0,
-        treeForkProvider = null,
-        treeForkCount = 0,
-        idStack = [],
-        idStackIndex = 0,
-        treeContextProvider = null,
-        treeContextId = 1,
-        treeContextOverflow = "";
-      function pushTreeFork(workInProgress, totalChildren) {
-        forkStack[forkStackIndex++] = treeForkCount;
-        forkStack[forkStackIndex++] = treeForkProvider;
-        treeForkProvider = workInProgress;
-        treeForkCount = totalChildren;
-      }
-      function pushTreeId(workInProgress, totalChildren, index) {
-        idStack[idStackIndex++] = treeContextId;
-        idStack[idStackIndex++] = treeContextOverflow;
-        idStack[idStackIndex++] = treeContextProvider;
-        treeContextProvider = workInProgress;
-        var baseIdWithLeadingBit = treeContextId;
-        workInProgress = treeContextOverflow;
-        var baseLength = 32 - clz32(baseIdWithLeadingBit) - 1;
-        baseIdWithLeadingBit &= ~(1 << baseLength);
-        index += 1;
-        var length = 32 - clz32(totalChildren) + baseLength;
-        if (30 < length) {
-          var numberOfOverflowBits = baseLength - (baseLength % 5);
-          length = (
-            baseIdWithLeadingBit &
-            ((1 << numberOfOverflowBits) - 1)
-          ).toString(32);
-          baseIdWithLeadingBit >>= numberOfOverflowBits;
-          baseLength -= numberOfOverflowBits;
-          treeContextId =
-            (1 << (32 - clz32(totalChildren) + baseLength)) |
-            (index << baseLength) |
-            baseIdWithLeadingBit;
-          treeContextOverflow = length + workInProgress;
-        } else
-          (treeContextId =
-            (1 << length) | (index << baseLength) | baseIdWithLeadingBit),
-            (treeContextOverflow = workInProgress);
-      }
-      function pushMaterializedTreeId(workInProgress) {
-        null !== workInProgress.return &&
-          (pushTreeFork(workInProgress, 1), pushTreeId(workInProgress, 1, 0));
-      }
-      function popTreeContext(workInProgress) {
-        for (; workInProgress === treeForkProvider; )
-          (treeForkProvider = forkStack[--forkStackIndex]),
-            (forkStack[forkStackIndex] = null),
-            (treeForkCount = forkStack[--forkStackIndex]),
-            (forkStack[forkStackIndex] = null);
-        for (; workInProgress === treeContextProvider; )
-          (treeContextProvider = idStack[--idStackIndex]),
-            (idStack[idStackIndex] = null),
-            (treeContextOverflow = idStack[--idStackIndex]),
-            (idStack[idStackIndex] = null),
-            (treeContextId = idStack[--idStackIndex]),
-            (idStack[idStackIndex] = null);
-      }
       var SuspenseException = Error(formatProdErrorMessage(460)),
         SuspenseyCommitException = Error(formatProdErrorMessage(474)),
         SuspenseActionException = Error(formatProdErrorMessage(542)),
@@ -7446,17 +7624,14 @@
               workInProgress.child
             );
           case 5:
-            return (
-              null === current &&
-                isHydrating &&
-                ((lazyComponent = nextHydratableInstance),
-                (init = !lazyComponent) ||
-                  ((lazyComponent = canHydrateInstance(
-                    lazyComponent,
-                    workInProgress.type,
-                    workInProgress.pendingProps,
-                    rootOrSingletonContext
-                  )),
+            if (null === current && isHydrating) {
+              if ((init = lazyComponent = nextHydratableInstance))
+                (lazyComponent = canHydrateInstance(
+                  lazyComponent,
+                  workInProgress.type,
+                  workInProgress.pendingProps,
+                  rootOrSingletonContext
+                )),
                   null !== lazyComponent
                     ? ((workInProgress.stateNode = lazyComponent),
                       (hydrationParentFiber = workInProgress),
@@ -7464,60 +7639,55 @@
                         lazyComponent.firstChild
                       )),
                       (rootOrSingletonContext = !1),
-                      (lazyComponent = !0))
-                    : (lazyComponent = !1),
-                  (init = !lazyComponent)),
-                init && throwOnHydrationMismatch(workInProgress)),
-              pushHostContext(workInProgress),
-              (init = workInProgress.type),
-              (nextProps = workInProgress.pendingProps),
-              (nextState = null !== current ? current.memoizedProps : null),
-              (lazyComponent = nextProps.children),
-              shouldSetTextContent(init, nextProps)
-                ? (lazyComponent = null)
-                : null !== nextState &&
-                  shouldSetTextContent(init, nextState) &&
-                  (workInProgress.flags |= 32),
-              null !== workInProgress.memoizedState &&
-                ((init = renderWithHooks(
-                  current,
-                  workInProgress,
-                  TransitionAwareHostComponent,
-                  null,
-                  null,
-                  renderLanes
-                )),
-                (HostTransitionContext._currentValue = init)),
-              markRef(current, workInProgress),
-              reconcileChildren(
+                      (init = !0))
+                    : (init = !1);
+              init || throwOnHydrationMismatch(workInProgress);
+            }
+            pushHostContext(workInProgress);
+            init = workInProgress.type;
+            nextProps = workInProgress.pendingProps;
+            nextState = null !== current ? current.memoizedProps : null;
+            lazyComponent = nextProps.children;
+            shouldSetTextContent(init, nextProps)
+              ? (lazyComponent = null)
+              : null !== nextState &&
+                shouldSetTextContent(init, nextState) &&
+                (workInProgress.flags |= 32);
+            null !== workInProgress.memoizedState &&
+              ((init = renderWithHooks(
                 current,
                 workInProgress,
-                lazyComponent,
+                TransitionAwareHostComponent,
+                null,
+                null,
                 renderLanes
-              ),
-              workInProgress.child
+              )),
+              (HostTransitionContext._currentValue = init));
+            markRef(current, workInProgress);
+            reconcileChildren(
+              current,
+              workInProgress,
+              lazyComponent,
+              renderLanes
             );
+            return workInProgress.child;
           case 6:
-            return (
-              null === current &&
-                isHydrating &&
-                ((renderLanes = nextHydratableInstance),
-                (current = !renderLanes) ||
-                  ((renderLanes = canHydrateTextInstance(
-                    renderLanes,
-                    workInProgress.pendingProps,
-                    rootOrSingletonContext
-                  )),
+            if (null === current && isHydrating) {
+              if ((current = renderLanes = nextHydratableInstance))
+                (renderLanes = canHydrateTextInstance(
+                  renderLanes,
+                  workInProgress.pendingProps,
+                  rootOrSingletonContext
+                )),
                   null !== renderLanes
                     ? ((workInProgress.stateNode = renderLanes),
                       (hydrationParentFiber = workInProgress),
                       (nextHydratableInstance = null),
-                      (renderLanes = !0))
-                    : (renderLanes = !1),
-                  (current = !renderLanes)),
-                current && throwOnHydrationMismatch(workInProgress)),
-              null
-            );
+                      (current = !0))
+                    : (current = !1);
+              current || throwOnHydrationMismatch(workInProgress);
+            }
+            return null;
           case 13:
             return updateSuspenseComponent(
               current,
@@ -7790,14 +7960,15 @@
         try {
           var ref = current.ref;
           if (null !== ref) {
+            var instance = current.stateNode;
             switch (current.tag) {
               case 26:
               case 27:
               case 5:
-                var instanceToUse = current.stateNode;
+                var instanceToUse = instance;
                 break;
               default:
-                instanceToUse = current.stateNode;
+                instanceToUse = instance;
             }
             "function" === typeof ref
               ? (current.refCleanup = ref(instanceToUse))
@@ -9985,184 +10156,6 @@
         };
         return mode;
       }
-      var hydrationParentFiber = null,
-        nextHydratableInstance = null,
-        isHydrating = !1,
-        hydrationErrors = null,
-        rootOrSingletonContext = !1,
-        HydrationMismatchException = Error(formatProdErrorMessage(519));
-      function throwOnHydrationMismatch(fiber) {
-        var error = Error(formatProdErrorMessage(418, ""));
-        queueHydrationError(createCapturedValueAtFiber(error, fiber));
-        throw HydrationMismatchException;
-      }
-      function prepareToHydrateHostInstance(fiber) {
-        var instance = fiber.stateNode,
-          type = fiber.type,
-          props = fiber.memoizedProps;
-        instance[internalInstanceKey] = fiber;
-        instance[internalPropsKey] = props;
-        switch (type) {
-          case "dialog":
-            listenToNonDelegatedEvent("cancel", instance);
-            listenToNonDelegatedEvent("close", instance);
-            break;
-          case "iframe":
-          case "object":
-          case "embed":
-            listenToNonDelegatedEvent("load", instance);
-            break;
-          case "video":
-          case "audio":
-            for (type = 0; type < mediaEventTypes.length; type++)
-              listenToNonDelegatedEvent(mediaEventTypes[type], instance);
-            break;
-          case "source":
-            listenToNonDelegatedEvent("error", instance);
-            break;
-          case "img":
-          case "image":
-          case "link":
-            listenToNonDelegatedEvent("error", instance);
-            listenToNonDelegatedEvent("load", instance);
-            break;
-          case "details":
-            listenToNonDelegatedEvent("toggle", instance);
-            break;
-          case "input":
-            listenToNonDelegatedEvent("invalid", instance);
-            initInput(
-              instance,
-              props.value,
-              props.defaultValue,
-              props.checked,
-              props.defaultChecked,
-              props.type,
-              props.name,
-              !0
-            );
-            track(instance);
-            break;
-          case "select":
-            listenToNonDelegatedEvent("invalid", instance);
-            break;
-          case "textarea":
-            listenToNonDelegatedEvent("invalid", instance),
-              initTextarea(
-                instance,
-                props.value,
-                props.defaultValue,
-                props.children
-              ),
-              track(instance);
-        }
-        type = props.children;
-        ("string" !== typeof type &&
-          "number" !== typeof type &&
-          "bigint" !== typeof type) ||
-        instance.textContent === "" + type ||
-        !0 === props.suppressHydrationWarning ||
-        checkForUnmatchedText(instance.textContent, type)
-          ? (null != props.popover &&
-              (listenToNonDelegatedEvent("beforetoggle", instance),
-              listenToNonDelegatedEvent("toggle", instance)),
-            null != props.onScroll &&
-              listenToNonDelegatedEvent("scroll", instance),
-            null != props.onScrollEnd &&
-              listenToNonDelegatedEvent("scrollend", instance),
-            null != props.onClick && (instance.onclick = noop$1),
-            (instance = !0))
-          : (instance = !1);
-        instance || throwOnHydrationMismatch(fiber);
-      }
-      function popToNextHostParent(fiber) {
-        for (hydrationParentFiber = fiber.return; hydrationParentFiber; )
-          switch (hydrationParentFiber.tag) {
-            case 3:
-            case 27:
-              rootOrSingletonContext = !0;
-              return;
-            case 5:
-            case 13:
-              rootOrSingletonContext = !1;
-              return;
-            default:
-              hydrationParentFiber = hydrationParentFiber.return;
-          }
-      }
-      function popHydrationState(fiber) {
-        if (fiber !== hydrationParentFiber) return !1;
-        if (!isHydrating)
-          return popToNextHostParent(fiber), (isHydrating = !0), !1;
-        var shouldClear = !1,
-          JSCompiler_temp;
-        if ((JSCompiler_temp = 3 !== fiber.tag && 27 !== fiber.tag)) {
-          if ((JSCompiler_temp = 5 === fiber.tag))
-            (JSCompiler_temp = fiber.type),
-              (JSCompiler_temp =
-                !("form" !== JSCompiler_temp && "button" !== JSCompiler_temp) ||
-                shouldSetTextContent(fiber.type, fiber.memoizedProps));
-          JSCompiler_temp = !JSCompiler_temp;
-        }
-        JSCompiler_temp && (shouldClear = !0);
-        shouldClear &&
-          nextHydratableInstance &&
-          throwOnHydrationMismatch(fiber);
-        popToNextHostParent(fiber);
-        if (13 === fiber.tag) {
-          fiber = fiber.memoizedState;
-          fiber = null !== fiber ? fiber.dehydrated : null;
-          if (!fiber) throw Error(formatProdErrorMessage(317));
-          a: {
-            fiber = fiber.nextSibling;
-            for (shouldClear = 0; fiber; ) {
-              if (8 === fiber.nodeType)
-                if (
-                  ((JSCompiler_temp = fiber.data), "/$" === JSCompiler_temp)
-                ) {
-                  if (0 === shouldClear) {
-                    nextHydratableInstance = getNextHydratable(
-                      fiber.nextSibling
-                    );
-                    break a;
-                  }
-                  shouldClear--;
-                } else
-                  ("$" !== JSCompiler_temp &&
-                    "$!" !== JSCompiler_temp &&
-                    "$?" !== JSCompiler_temp) ||
-                    shouldClear++;
-              fiber = fiber.nextSibling;
-            }
-            nextHydratableInstance = null;
-          }
-        } else
-          nextHydratableInstance = hydrationParentFiber
-            ? getNextHydratable(fiber.stateNode.nextSibling)
-            : null;
-        return !0;
-      }
-      function resetHydrationState() {
-        nextHydratableInstance = hydrationParentFiber = null;
-        isHydrating = !1;
-      }
-      function upgradeHydrationErrorsToRecoverable() {
-        var queuedErrors = hydrationErrors;
-        null !== queuedErrors &&
-          (null === workInProgressRootRecoverableErrors
-            ? (workInProgressRootRecoverableErrors = queuedErrors)
-            : workInProgressRootRecoverableErrors.push.apply(
-                workInProgressRootRecoverableErrors,
-                queuedErrors
-              ),
-          (hydrationErrors = null));
-        return queuedErrors;
-      }
-      function queueHydrationError(error) {
-        null === hydrationErrors
-          ? (hydrationErrors = [error])
-          : hydrationErrors.push(error);
-      }
       function markUpdate(workInProgress) {
         workInProgress.flags |= 4;
       }
@@ -12508,20 +12501,20 @@
         }
       }
       for (
-        var i$jscomp$inline_1490 = 0;
-        i$jscomp$inline_1490 < simpleEventPluginEvents.length;
-        i$jscomp$inline_1490++
+        var i$jscomp$inline_1474 = 0;
+        i$jscomp$inline_1474 < simpleEventPluginEvents.length;
+        i$jscomp$inline_1474++
       ) {
-        var eventName$jscomp$inline_1491 =
-            simpleEventPluginEvents[i$jscomp$inline_1490],
-          domEventName$jscomp$inline_1492 =
-            eventName$jscomp$inline_1491.toLowerCase(),
-          capitalizedEvent$jscomp$inline_1493 =
-            eventName$jscomp$inline_1491[0].toUpperCase() +
-            eventName$jscomp$inline_1491.slice(1);
+        var eventName$jscomp$inline_1475 =
+            simpleEventPluginEvents[i$jscomp$inline_1474],
+          domEventName$jscomp$inline_1476 =
+            eventName$jscomp$inline_1475.toLowerCase(),
+          capitalizedEvent$jscomp$inline_1477 =
+            eventName$jscomp$inline_1475[0].toUpperCase() +
+            eventName$jscomp$inline_1475.slice(1);
         registerSimpleEvent(
-          domEventName$jscomp$inline_1492,
-          "on" + capitalizedEvent$jscomp$inline_1493
+          domEventName$jscomp$inline_1476,
+          "on" + capitalizedEvent$jscomp$inline_1477
         );
       }
       registerSimpleEvent(ANIMATION_END, "onAnimationEnd");
@@ -16207,16 +16200,16 @@
           0 === i && attemptExplicitHydrationTarget(target);
         }
       };
-      var isomorphicReactPackageVersion$jscomp$inline_1737 = React.version;
+      var isomorphicReactPackageVersion$jscomp$inline_1721 = React.version;
       if (
-        "19.1.0-canary-cabd8a0e-20250113" !==
-        isomorphicReactPackageVersion$jscomp$inline_1737
+        "19.1.0-canary-74ea0c73-20250109" !==
+        isomorphicReactPackageVersion$jscomp$inline_1721
       )
         throw Error(
           formatProdErrorMessage(
             527,
-            isomorphicReactPackageVersion$jscomp$inline_1737,
-            "19.1.0-canary-cabd8a0e-20250113"
+            isomorphicReactPackageVersion$jscomp$inline_1721,
+            "19.1.0-canary-74ea0c73-20250109"
           )
         );
       ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16236,24 +16229,24 @@
           null === componentOrElement ? null : componentOrElement.stateNode;
         return componentOrElement;
       };
-      var internals$jscomp$inline_2214 = {
+      var internals$jscomp$inline_2190 = {
         bundleType: 0,
-        version: "19.1.0-canary-cabd8a0e-20250113",
+        version: "19.1.0-canary-74ea0c73-20250109",
         rendererPackageName: "react-dom",
         currentDispatcherRef: ReactSharedInternals,
-        reconcilerVersion: "19.1.0-canary-cabd8a0e-20250113",
+        reconcilerVersion: "19.1.0-canary-74ea0c73-20250109",
       };
       if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
-        var hook$jscomp$inline_2215 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
+        var hook$jscomp$inline_2191 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
         if (
-          !hook$jscomp$inline_2215.isDisabled &&
-          hook$jscomp$inline_2215.supportsFiber
+          !hook$jscomp$inline_2191.isDisabled &&
+          hook$jscomp$inline_2191.supportsFiber
         )
           try {
-            (rendererID = hook$jscomp$inline_2215.inject(
-              internals$jscomp$inline_2214
+            (rendererID = hook$jscomp$inline_2191.inject(
+              internals$jscomp$inline_2190
             )),
-              (injectedHook = hook$jscomp$inline_2215);
+              (injectedHook = hook$jscomp$inline_2191);
           } catch (err) {}
       }
       exports.createRoot = function (container, options) {
@@ -16351,7 +16344,7 @@
         listenToAllSupportedEvents(container);
         return new ReactDOMHydrationRoot(initialChildren);
       };
-      exports.version = "19.1.0-canary-cabd8a0e-20250113";
+      exports.version = "19.1.0-canary-74ea0c73-20250109";
 
       /***/
     },
Diff for main-HASH.js

Diff too large to display

Diff for app-page-exp..ntime.dev.js
failed to diff
Diff for app-page-exp..time.prod.js

Diff too large to display

Diff for app-page.runtime.dev.js
failed to diff
Diff for app-page.runtime.prod.js

Diff too large to display

Diff for server.runtime.prod.js
failed to diff
Commit: 4a9d1af

@ijjk
Copy link
Copy Markdown
Member

ijjk commented Jan 10, 2025

Tests Passed

@wyattjoh wyattjoh force-pushed the feat/rewrite-headers branch from 9bfdd8a to 4a9d1af Compare January 13, 2025 21:36
@wyattjoh wyattjoh marked this pull request as ready for review January 13, 2025 22:37
@wyattjoh wyattjoh requested a review from ijjk January 13, 2025 23:05
@wyattjoh wyattjoh merged commit 1c56ef6 into canary Jan 13, 2025
@wyattjoh wyattjoh deleted the feat/rewrite-headers branch January 13, 2025 23:15
github-merge-queue bot pushed a commit to vercel/vercel that referenced this pull request Jan 21, 2025
For Next.js projects where it's enabled, this adds new
`x-nextjs-rewritten-path` and `x-nextjs-rewritten-query` headers to
user-supplied rewrites. This is designed to assist the new client router
changes that will utilize these headers for creating client router cache
keys.

vercel/next.js#74776
wyattjoh added a commit to vercel/vercel that referenced this pull request Jan 21, 2025
For Next.js projects where it's enabled, this adds new
`x-nextjs-rewritten-path` and `x-nextjs-rewritten-query` headers to
user-supplied rewrites. This is designed to assist the new client router
changes that will utilize these headers for creating client router cache
keys.

vercel/next.js#74776
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants