Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Head.rewind as it's no longer needed #14091

Merged
merged 7 commits into from
Jun 11, 2020

Conversation

timneutkens
Copy link
Member

Fixes #9326

@ijjk
Copy link
Member

ijjk commented Jun 11, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
buildDuration 11.8s 11.3s -509ms
nodeModulesSize 64.9 MB 64.9 MB -2.03 kB
Page Load Tests Overall increase ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
/ failed reqs 0 0
/ total time (seconds) 2.09 2.003 -0.09
/ avg req/sec 1195.95 1248.17 ⚠️ +52.22
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.447 1.28 -0.17
/error-in-render avg req/sec 1727.92 1952.78 ⚠️ +224.86
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
main-HASH.js gzip 6.49 kB 6.51 kB ⚠️ +18 B
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..0538.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.9 kB 56.9 kB ⚠️ +18 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
main-HASH.module.js gzip 5.58 kB 5.6 kB ⚠️ +20 B
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.4 kB 52.4 kB ⚠️ +20 B
Legacy Client Bundles (polyfills)
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
hooks.js gzip 881 B 881 B
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB N/A N/A
Overall change 8.22 kB 4.97 kB -3.25 kB
Client Pages Modern Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
index.module.js gzip 223 B 223 B
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
_error.module.js gzip 2.04 kB N/A N/A
hooks.module.js gzip 383 B 383 B
link.module.js gzip 1.52 kB 1.52 kB
_app.module.js gzip 604 B 604 B
Overall change 5.33 kB 3.29 kB -2.04 kB
Client Build Manifests Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
_buildManifest.js gzip 270 B 270 B
_buildManife..dule.js gzip 275 B 274 B -1 B
Overall change 545 B 544 B -1 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
index.html gzip 954 B 957 B ⚠️ +3 B
link.html gzip 961 B 963 B ⚠️ +2 B
withRouter.html gzip 947 B 951 B ⚠️ +4 B
Overall change 2.86 kB 2.87 kB ⚠️ +9 B

Diffs

Diff for _error.module.js
@@ -192,7 +192,7 @@
       exports.defaultHead = defaultHead;
       exports.default = void 0;
 
-      var _react = _interopRequireDefault(__webpack_require__("q1tI"));
+      var _react = _interopRequireWildcard(__webpack_require__("q1tI"));
 
       var _sideEffect = _interopRequireDefault(__webpack_require__("Xuae"));
 
@@ -210,6 +210,64 @@
             };
       }
 
+      function _getRequireWildcardCache() {
+        if (typeof WeakMap !== "function") return null;
+        var cache = new WeakMap();
+
+        _getRequireWildcardCache = function _getRequireWildcardCache() {
+          return cache;
+        };
+
+        return cache;
+      }
+
+      function _interopRequireWildcard(obj) {
+        if (obj && obj.__esModule) {
+          return obj;
+        }
+
+        if (
+          obj === null ||
+          (typeof obj !== "object" && typeof obj !== "function")
+        ) {
+          return {
+            default: obj
+          };
+        }
+
+        var cache = _getRequireWildcardCache();
+
+        if (cache && cache.has(obj)) {
+          return cache.get(obj);
+        }
+
+        var newObj = {};
+        var hasPropertyDescriptor =
+          Object.defineProperty && Object.getOwnPropertyDescriptor;
+
+        for (var key in obj) {
+          if (Object.prototype.hasOwnProperty.call(obj, key)) {
+            var desc = hasPropertyDescriptor
+              ? Object.getOwnPropertyDescriptor(obj, key)
+              : null;
+
+            if (desc && (desc.get || desc.set)) {
+              Object.defineProperty(newObj, key, desc);
+            } else {
+              newObj[key] = obj[key];
+            }
+          }
+        }
+
+        newObj.default = obj;
+
+        if (cache) {
+          cache.set(obj, newObj);
+        }
+
+        return newObj;
+      }
+
       function defaultHead() {
         var inAmpMode =
           arguments.length > 0 && arguments[0] !== undefined
@@ -352,8 +410,6 @@ Also adds support for deduplicated `key` properties
             });
           });
       }
-
-      var Effect = (0, _sideEffect.default)();
       /**
        * This component injects elements to `<head>` of your page.
        * To avoid duplicated `tags` in `<head>` you can use the `key` property, which will make sure every tag is only rendered once.
@@ -361,28 +417,23 @@ Also adds support for deduplicated `key` properties
 
       function Head(_ref) {
         var { children } = _ref;
+        var ampState = (0, _react.useContext)(_ampContext.AmpStateContext);
+        var headManager = (0, _react.useContext)(
+          _headManagerContext.HeadManagerContext
+        );
         return /*#__PURE__*/ _react.default.createElement(
-          _ampContext.AmpStateContext.Consumer,
-          null,
-          ampState =>
-            /*#__PURE__*/ _react.default.createElement(
-              _headManagerContext.HeadManagerContext.Consumer,
-              null,
-              updateHead =>
-                /*#__PURE__*/ _react.default.createElement(
-                  Effect,
-                  {
-                    reduceComponentsToState: reduceComponents,
-                    handleStateChange: updateHead,
-                    inAmpMode: (0, _amp.isInAmpMode)(ampState)
-                  },
-                  children
-                )
-            )
+          _sideEffect.default,
+          {
+            reduceComponentsToState: reduceComponents,
+            headManager: headManager,
+            inAmpMode: (0, _amp.isInAmpMode)(ampState)
+          },
+          children
         );
-      }
+      } // TODO: Remove in the next major release
+
+      Head.rewind = () => {};
 
-      Head.rewind = Effect.rewind;
       var _default = Head;
       exports.default = _default;
 
@@ -405,7 +456,7 @@ Also adds support for deduplicated `key` properties
             };
       }
 
-      var HeadManagerContext = _react.default.createContext(null);
+      var HeadManagerContext = _react.default.createContext({});
 
       exports.HeadManagerContext = HeadManagerContext;
 
@@ -449,58 +500,43 @@ Also adds support for deduplicated `key` properties
 
       var isServer = false;
 
-      var _default = () => {
-        var mountedInstances = new Set();
-        var state;
+      class _default extends _react.Component {
+        constructor(props) {
+          super(props);
 
-        function emitChange(component) {
-          state = component.props.reduceComponentsToState(
-            [...mountedInstances],
-            component.props
-          );
+          this.emitChange = () => {
+            this.props.headManager.updateHead(
+              this.props.reduceComponentsToState(
+                [...this.props.headManager.mountedInstances],
+                this.props
+              )
+            );
+          };
 
-          if (component.props.handleStateChange) {
-            component.props.handleStateChange(state);
+          if (isServer) {
+            this.props.headManager.mountedInstances.add(this);
+            this.emitChange();
           }
         }
 
-        return class extends _react.Component {
-          // Used when server rendering
-          static rewind() {
-            var recordedState = state;
-            state = undefined;
-            mountedInstances.clear();
-            return recordedState;
-          }
-
-          constructor(props) {
-            super(props);
-
-            if (isServer) {
-              mountedInstances.add(this);
-              emitChange(this);
-            }
-          }
-
-          componentDidMount() {
-            mountedInstances.add(this);
-            emitChange(this);
-          }
+        componentDidMount() {
+          this.props.headManager.mountedInstances.add(this);
+          this.emitChange();
+        }
 
-          componentDidUpdate() {
-            emitChange(this);
-          }
+        componentDidUpdate() {
+          this.emitChange();
+        }
 
-          componentWillUnmount() {
-            mountedInstances.delete(this);
-            emitChange(this);
-          }
+        componentWillUnmount() {
+          this.props.headManager.mountedInstances.delete(this);
+          this.emitChange();
+        }
 
-          render() {
-            return null;
-          }
-        };
-      };
+        render() {
+          return null;
+        }
+      }
 
       exports.default = _default;
Diff for _error.js
@@ -281,7 +281,7 @@
       exports.defaultHead = defaultHead;
       exports["default"] = void 0;
 
-      var _react = _interopRequireDefault(__webpack_require__("q1tI"));
+      var _react = _interopRequireWildcard(__webpack_require__("q1tI"));
 
       var _sideEffect = _interopRequireDefault(__webpack_require__("Xuae"));
 
@@ -299,6 +299,64 @@
             };
       }
 
+      function _getRequireWildcardCache() {
+        if (typeof WeakMap !== "function") return null;
+        var cache = new WeakMap();
+
+        _getRequireWildcardCache = function _getRequireWildcardCache() {
+          return cache;
+        };
+
+        return cache;
+      }
+
+      function _interopRequireWildcard(obj) {
+        if (obj && obj.__esModule) {
+          return obj;
+        }
+
+        if (
+          obj === null ||
+          (typeof obj !== "object" && typeof obj !== "function")
+        ) {
+          return {
+            default: obj
+          };
+        }
+
+        var cache = _getRequireWildcardCache();
+
+        if (cache && cache.has(obj)) {
+          return cache.get(obj);
+        }
+
+        var newObj = {};
+        var hasPropertyDescriptor =
+          Object.defineProperty && Object.getOwnPropertyDescriptor;
+
+        for (var key in obj) {
+          if (Object.prototype.hasOwnProperty.call(obj, key)) {
+            var desc = hasPropertyDescriptor
+              ? Object.getOwnPropertyDescriptor(obj, key)
+              : null;
+
+            if (desc && (desc.get || desc.set)) {
+              Object.defineProperty(newObj, key, desc);
+            } else {
+              newObj[key] = obj[key];
+            }
+          }
+        }
+
+        newObj["default"] = obj;
+
+        if (cache) {
+          cache.set(obj, newObj);
+        }
+
+        return newObj;
+      }
+
       function defaultHead() {
         var inAmpMode =
           arguments.length > 0 && arguments[0] !== undefined
@@ -441,8 +499,6 @@ Also adds support for deduplicated `key` properties
             });
           });
       }
-
-      var Effect = (0, _sideEffect["default"])();
       /**
        * This component injects elements to `<head>` of your page.
        * To avoid duplicated `tags` in `<head>` you can use the `key` property, which will make sure every tag is only rendered once.
@@ -450,30 +506,23 @@ Also adds support for deduplicated `key` properties
 
       function Head(_ref) {
         var children = _ref.children;
+        var ampState = (0, _react.useContext)(_ampContext.AmpStateContext);
+        var headManager = (0, _react.useContext)(
+          _headManagerContext.HeadManagerContext
+        );
         return /*#__PURE__*/ _react["default"].createElement(
-          _ampContext.AmpStateContext.Consumer,
-          null,
-          function(ampState) {
-            return /*#__PURE__*/ _react["default"].createElement(
-              _headManagerContext.HeadManagerContext.Consumer,
-              null,
-              function(updateHead) {
-                return /*#__PURE__*/ _react["default"].createElement(
-                  Effect,
-                  {
-                    reduceComponentsToState: reduceComponents,
-                    handleStateChange: updateHead,
-                    inAmpMode: (0, _amp.isInAmpMode)(ampState)
-                  },
-                  children
-                );
-              }
-            );
-          }
+          _sideEffect["default"],
+          {
+            reduceComponentsToState: reduceComponents,
+            headManager: headManager,
+            inAmpMode: (0, _amp.isInAmpMode)(ampState)
+          },
+          children
         );
-      }
+      } // TODO: Remove in the next major release
+
+      Head.rewind = function() {};
 
-      Head.rewind = Effect.rewind;
       var _default = Head;
       exports["default"] = _default;
 
@@ -519,7 +568,7 @@ Also adds support for deduplicated `key` properties
             };
       }
 
-      var HeadManagerContext = _react["default"].createContext(null);
+      var HeadManagerContext = _react["default"].createContext({});
 
       exports.HeadManagerContext = HeadManagerContext;
 
@@ -677,20 +726,20 @@ Also adds support for deduplicated `key` properties
     /***/ Xuae: /***/ function(module, exports, __webpack_require__) {
       "use strict";
 
-      var _classCallCheck = __webpack_require__("lwsE");
+      var _toConsumableArray = __webpack_require__("RIqP");
 
-      var _assertThisInitialized = __webpack_require__("PJYZ");
+      var _classCallCheck = __webpack_require__("lwsE");
 
       var _createClass = __webpack_require__("W8MJ");
 
+      var _assertThisInitialized = __webpack_require__("PJYZ");
+
       var _inherits = __webpack_require__("7W2i");
 
       var _possibleConstructorReturn = __webpack_require__("a1gu");
 
       var _getPrototypeOf = __webpack_require__("Nsbk");
 
-      var _toConsumableArray = __webpack_require__("RIqP");
-
       function _createSuper(Derived) {
         var hasNativeReflectConstruct = _isNativeReflectConstruct();
         return function _createSuperInternal() {
@@ -727,86 +776,69 @@ Also adds support for deduplicated `key` properties
 
       var isServer = false;
 
-      var _default = function _default() {
-        var mountedInstances = new Set();
-        var state;
+      var _default = /*#__PURE__*/ (function(_react$Component) {
+        _inherits(_default, _react$Component);
 
-        function emitChange(component) {
-          state = component.props.reduceComponentsToState(
-            _toConsumableArray(mountedInstances),
-            component.props
-          );
+        var _super = _createSuper(_default);
 
-          if (component.props.handleStateChange) {
-            component.props.handleStateChange(state);
-          }
-        }
+        function _default(props) {
+          var _this;
 
-        return /*#__PURE__*/ (function(_react$Component) {
-          _inherits(_class, _react$Component);
+          _classCallCheck(this, _default);
 
-          var _super = _createSuper(_class);
+          _this = _super.call(this, props);
 
-          _createClass(_class, null, [
-            {
-              key: "rewind",
-              // Used when server rendering
-              value: function rewind() {
-                var recordedState = state;
-                state = undefined;
-                mountedInstances.clear();
-                return recordedState;
-              }
-            }
-          ]);
+          _this.emitChange = function() {
+            _this.props.headManager.updateHead(
+              _this.props.reduceComponentsToState(
+                _toConsumableArray(_this.props.headManager.mountedInstances),
+                _this.props
+              )
+            );
+          };
 
-          function _class(props) {
-            var _this;
+          if (isServer) {
+            _this.props.headManager.mountedInstances.add(
+              _assertThisInitialized(_this)
+            );
 
-            _classCallCheck(this, _class);
+            _this.emitChange();
+          }
 
-            _this = _super.call(this, props);
+          return _this;
+        }
 
-            if (isServer) {
-              mountedInstances.add(_assertThisInitialized(_this));
-              emitChange(_assertThisInitialized(_this));
+        _createClass(_default, [
+          {
+            key: "componentDidMount",
+            value: function componentDidMount() {
+              this.props.headManager.mountedInstances.add(this);
+              this.emitChange();
             }
-
-            return _this;
-          }
-
-          _createClass(_class, [
-            {
-              key: "componentDidMount",
-              value: function componentDidMount() {
-                mountedInstances.add(this);
-                emitChange(this);
-              }
-            },
-            {
-              key: "componentDidUpdate",
-              value: function componentDidUpdate() {
-                emitChange(this);
-              }
-            },
-            {
-              key: "componentWillUnmount",
-              value: function componentWillUnmount() {
-                mountedInstances["delete"](this);
-                emitChange(this);
-              }
-            },
-            {
-              key: "render",
-              value: function render() {
-                return null;
-              }
+          },
+          {
+            key: "componentDidUpdate",
+            value: function componentDidUpdate() {
+              this.emitChange();
             }
-          ]);
+          },
+          {
+            key: "componentWillUnmount",
+            value: function componentWillUnmount() {
+              this.props.headManager.mountedInstances["delete"](this);
+              this.emitChange();
+            }
+          },
+          {
+            key: "render",
+            value: function render() {
+              return null;
+            }
+          }
+        ]);
 
-          return _class;
-        })(_react.Component);
-      };
+        return _default;
+      })(_react.Component);
 
       exports["default"] = _default;
Diff for _buildManifest.js
@@ -1,6 +1,6 @@
 self.__BUILD_MANIFEST = {
   "/": ["static\u002F8f6ec52978e4ed685749\u002Fpages\u002Findex.js"],
-  "/_error": ["static\u002F0dd45ce0aa0f4454606b\u002Fpages\u002F_error.js"],
+  "/_error": ["static\u002F280ae3949913ae3eca18\u002Fpages\u002F_error.js"],
   "/hooks": ["static\u002F701db499b372d8b4ad8a\u002Fpages\u002Fhooks.js"],
   "/link": ["static\u002Fe826d21ad4f09aa9e68e\u002Fpages\u002Flink.js"],
   "/routerDirect": [
Diff for _buildManifest.module.js
@@ -1,7 +1,7 @@
 self.__BUILD_MANIFEST = {
   "/": ["static\u002F617084c2156e7a4c3a6e\u002Fpages\u002Findex.module.js"],
   "/_error": [
-    "static\u002F044e777feb8a752b7656\u002Fpages\u002F_error.module.js"
+    "static\u002F4945a630f79d7fe38292\u002Fpages\u002F_error.module.js"
   ],
   "/hooks": [
     "static\u002F680ac2d033b0bc870c3a\u002Fpages\u002Fhooks.module.js"
Diff for main-HASH.js
@@ -129,30 +129,35 @@
 
       function initHeadManager() {
         var updatePromise = null;
-        return function(head) {
-          var promise = (updatePromise = Promise.resolve().then(function() {
-            if (promise !== updatePromise) return;
-            updatePromise = null;
-            var tags = {};
-            head.forEach(function(h) {
-              var components = tags[h.type] || [];
-              components.push(h);
-              tags[h.type] = components;
-            });
-            var titleComponent = tags.title ? tags.title[0] : null;
-            var title = "";
+        return {
+          mountedInstances: new Set(),
+          updateHead: function updateHead(head) {
+            var promise = (updatePromise = Promise.resolve().then(function() {
+              if (promise !== updatePromise) return;
+              updatePromise = null;
+              var tags = {};
+              head.forEach(function(h) {
+                var components = tags[h.type] || [];
+                components.push(h);
+                tags[h.type] = components;
+              });
+              var titleComponent = tags.title ? tags.title[0] : null;
+              var title = "";
 
-            if (titleComponent) {
-              var children = titleComponent.props.children;
-              title =
-                typeof children === "string" ? children : children.join("");
-            }
+              if (titleComponent) {
+                var children = titleComponent.props.children;
+                title =
+                  typeof children === "string" ? children : children.join("");
+              }
 
-            if (title !== document.title) document.title = title;
-            ["meta", "base", "link", "style", "script"].forEach(function(type) {
-              updateElements(type, tags[type] || []);
-            });
-          }));
+              if (title !== document.title) document.title = title;
+              ["meta", "base", "link", "style", "script"].forEach(function(
+                type
+              ) {
+                updateElements(type, tags[type] || []);
+              });
+            }));
+          }
         };
       }
 
@@ -175,7 +180,7 @@
             };
       }
 
-      var HeadManagerContext = _react["default"].createContext(null);
+      var HeadManagerContext = _react["default"].createContext({});
 
       exports.HeadManagerContext = HeadManagerContext;
 
@@ -333,7 +338,7 @@
 
       window.__NEXT_P = [];
       window.__NEXT_P.push = register;
-      var updateHead = (0, _headManager["default"])();
+      var headManager = (0, _headManager["default"])();
       var appElement = document.getElementById("__next");
       var lastAppProps;
 
@@ -899,7 +904,7 @@
             /*#__PURE__*/ _react["default"].createElement(
               _headManagerContext.HeadManagerContext.Provider,
               {
-                value: updateHead
+                value: headManager
               },
               children
             )
Diff for main-HASH.module.js
@@ -96,30 +96,33 @@
 
       function initHeadManager() {
         var updatePromise = null;
-        return head => {
-          var promise = (updatePromise = Promise.resolve().then(() => {
-            if (promise !== updatePromise) return;
-            updatePromise = null;
-            var tags = {};
-            head.forEach(h => {
-              var components = tags[h.type] || [];
-              components.push(h);
-              tags[h.type] = components;
-            });
-            var titleComponent = tags.title ? tags.title[0] : null;
-            var title = "";
+        return {
+          mountedInstances: new Set(),
+          updateHead: head => {
+            var promise = (updatePromise = Promise.resolve().then(() => {
+              if (promise !== updatePromise) return;
+              updatePromise = null;
+              var tags = {};
+              head.forEach(h => {
+                var components = tags[h.type] || [];
+                components.push(h);
+                tags[h.type] = components;
+              });
+              var titleComponent = tags.title ? tags.title[0] : null;
+              var title = "";
 
-            if (titleComponent) {
-              var { children } = titleComponent.props;
-              title =
-                typeof children === "string" ? children : children.join("");
-            }
+              if (titleComponent) {
+                var { children } = titleComponent.props;
+                title =
+                  typeof children === "string" ? children : children.join("");
+              }
 
-            if (title !== document.title) document.title = title;
-            ["meta", "base", "link", "style", "script"].forEach(type => {
-              updateElements(type, tags[type] || []);
-            });
-          }));
+              if (title !== document.title) document.title = title;
+              ["meta", "base", "link", "style", "script"].forEach(type => {
+                updateElements(type, tags[type] || []);
+              });
+            }));
+          }
         };
       }
 
@@ -142,7 +145,7 @@
             };
       }
 
-      var HeadManagerContext = _react.default.createContext(null);
+      var HeadManagerContext = _react.default.createContext({});
 
       exports.HeadManagerContext = HeadManagerContext;
 
@@ -248,7 +251,7 @@
 
       window.__NEXT_P = [];
       window.__NEXT_P.push = register;
-      var updateHead = (0, _headManager.default)();
+      var headManager = (0, _headManager.default)();
       var appElement = document.getElementById("__next");
       var lastAppProps;
       var lastRenderReject;
@@ -642,7 +645,7 @@
             /*#__PURE__*/ _react.default.createElement(
               _headManagerContext.HeadManagerContext.Provider,
               {
-                value: updateHead
+                value: headManager
               },
               children
             )
Diff for index.html
@@ -6,7 +6,7 @@
     <meta name="next-head-count" content="2" />
     <link
       rel="preload"
-      href="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      href="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -81,13 +81,13 @@
       src="/_next/static/runtime/polyfills-eaf5488e20ec921d713f.js"
     ></script>
     <script
-      src="/_next/static/runtime/main-0d66d3e4991e946c74e4.js"
+      src="/_next/static/runtime/main-5645e84ad489a13ad929.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      src="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -6,7 +6,7 @@
     <meta name="next-head-count" content="2" />
     <link
       rel="preload"
-      href="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      href="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -86,13 +86,13 @@
       src="/_next/static/runtime/polyfills-eaf5488e20ec921d713f.js"
     ></script>
     <script
-      src="/_next/static/runtime/main-0d66d3e4991e946c74e4.js"
+      src="/_next/static/runtime/main-5645e84ad489a13ad929.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      src="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -6,7 +6,7 @@
     <meta name="next-head-count" content="2" />
     <link
       rel="preload"
-      href="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      href="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -81,13 +81,13 @@
       src="/_next/static/runtime/polyfills-eaf5488e20ec921d713f.js"
     ></script>
     <script
-      src="/_next/static/runtime/main-0d66d3e4991e946c74e4.js"
+      src="/_next/static/runtime/main-5645e84ad489a13ad929.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      src="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
buildDuration 13s 12.4s -664ms
nodeModulesSize 64.9 MB 64.9 MB -2.03 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
main-HASH.js gzip 6.49 kB 6.51 kB ⚠️ +18 B
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..0538.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.9 kB 56.9 kB ⚠️ +18 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
main-HASH.module.js gzip 5.58 kB 5.6 kB ⚠️ +20 B
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.4 kB 52.4 kB ⚠️ +20 B
Legacy Client Bundles (polyfills)
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
hooks.js gzip 881 B 881 B
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.37 kB ⚠️ +123 B
Overall change 8.22 kB 8.34 kB ⚠️ +123 B
Client Pages Modern Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
index.module.js gzip 223 B 223 B
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
_error.module.js gzip 2.04 kB 2.21 kB ⚠️ +167 B
hooks.module.js gzip 383 B 383 B
link.module.js gzip 1.52 kB 1.52 kB
_app.module.js gzip 604 B 604 B
Overall change 5.33 kB 5.49 kB ⚠️ +167 B
Client Build Manifests Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
_buildManifest.js gzip 270 B 270 B
_buildManife..dule.js gzip 275 B 274 B -1 B
Overall change 545 B 544 B -1 B
Serverless bundles Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
_error.js 875 kB 875 kB -14 B
404.html 4.17 kB 4.17 kB
hooks.html 3.79 kB 3.79 kB
index.js 875 kB 875 kB -14 B
link.js 913 kB 913 kB -14 B
routerDirect.js 905 kB 905 kB -14 B
withRouter.js 905 kB 905 kB -14 B
Overall change 4.48 MB 4.48 MB -70 B

@ijjk
Copy link
Member

ijjk commented Jun 11, 2020

Failing test suites

test/integration/basic/test/index.test.js

  • Basic Features > Error Recovery > should recover after a bad return from the render function
Expand output

● Basic Features › Error Recovery › should recover after a bad return from the render function

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `Basic Features Error Recovery should recover after a bad return from the render function 1`

- Snapshot  - 0
+ Received  + 1

@@ -6,8 +6,9 @@
      in App
      in Unknown
      in Context.Provider
      in Context.Provider
      in Context.Provider
+     in Context.Provider
      in AppContainer

  This error happened while generating the page. Any console logs will be displayed in the terminal window.

  248 | 
  249 |         expect(await hasRedbox(browser)).toBe(true)
> 250 |         expect(await getRedboxHeader(browser)).toMatchInlineSnapshot(`
      |                                                ^
  251 |           " 1 of 1 unhandled error
  252 |           Server Error
  253 | 

  at Object.<anonymous> (integration/basic/test/error-recovery.js:250:48)

@ijjk
Copy link
Member

ijjk commented Jun 11, 2020

Failing test suites

test/integration/basic/test/index.test.js

  • Basic Features > Error Recovery > should recover after a bad return from the render function
Expand output

● Basic Features › Error Recovery › should recover after a bad return from the render function

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `Basic Features Error Recovery should recover after a bad return from the render function 1`

- Snapshot  - 0
+ Received  + 1

@@ -6,8 +6,9 @@
      in App
      in Unknown
      in Context.Provider
      in Context.Provider
      in Context.Provider
+     in Context.Provider
      in AppContainer

  This error happened while generating the page. Any console logs will be displayed in the terminal window.

  248 | 
  249 |         expect(await hasRedbox(browser)).toBe(true)
> 250 |         expect(await getRedboxHeader(browser)).toMatchInlineSnapshot(`
      |                                                ^
  251 |           " 1 of 1 unhandled error
  252 |           Server Error
  253 | 

  at Object.<anonymous> (integration/basic/test/error-recovery.js:250:48)

@ijjk
Copy link
Member

ijjk commented Jun 11, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
buildDuration 11.5s 11.9s ⚠️ +430ms
nodeModulesSize 64.9 MB 64.9 MB -2.5 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
/ failed reqs 0 0
/ total time (seconds) 1.927 1.963 ⚠️ +0.04
/ avg req/sec 1297.15 1273.85 -23.3
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.144 1.133 -0.01
/error-in-render avg req/sec 2186.15 2206.97 ⚠️ +20.82
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
main-HASH.js gzip 6.49 kB 6.51 kB ⚠️ +18 B
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..0538.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.9 kB 56.9 kB ⚠️ +18 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
main-HASH.module.js gzip 5.58 kB 5.6 kB ⚠️ +20 B
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.4 kB 52.4 kB ⚠️ +20 B
Legacy Client Bundles (polyfills)
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
hooks.js gzip 881 B 881 B
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB N/A N/A
Overall change 8.22 kB 4.97 kB -3.25 kB
Client Pages Modern Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
index.module.js gzip 223 B 223 B
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
_error.module.js gzip 2.04 kB N/A N/A
hooks.module.js gzip 383 B 383 B
link.module.js gzip 1.52 kB 1.52 kB
_app.module.js gzip 604 B 604 B
Overall change 5.33 kB 3.29 kB -2.04 kB
Client Build Manifests Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
_buildManifest.js gzip 270 B 270 B
_buildManife..dule.js gzip 275 B 274 B -1 B
Overall change 545 B 544 B -1 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
index.html gzip 954 B 957 B ⚠️ +3 B
link.html gzip 961 B 963 B ⚠️ +2 B
withRouter.html gzip 947 B 951 B ⚠️ +4 B
Overall change 2.86 kB 2.87 kB ⚠️ +9 B

Diffs

Diff for _error.module.js
@@ -192,7 +192,7 @@
       exports.defaultHead = defaultHead;
       exports.default = void 0;
 
-      var _react = _interopRequireDefault(__webpack_require__("q1tI"));
+      var _react = _interopRequireWildcard(__webpack_require__("q1tI"));
 
       var _sideEffect = _interopRequireDefault(__webpack_require__("Xuae"));
 
@@ -210,6 +210,64 @@
             };
       }
 
+      function _getRequireWildcardCache() {
+        if (typeof WeakMap !== "function") return null;
+        var cache = new WeakMap();
+
+        _getRequireWildcardCache = function _getRequireWildcardCache() {
+          return cache;
+        };
+
+        return cache;
+      }
+
+      function _interopRequireWildcard(obj) {
+        if (obj && obj.__esModule) {
+          return obj;
+        }
+
+        if (
+          obj === null ||
+          (typeof obj !== "object" && typeof obj !== "function")
+        ) {
+          return {
+            default: obj
+          };
+        }
+
+        var cache = _getRequireWildcardCache();
+
+        if (cache && cache.has(obj)) {
+          return cache.get(obj);
+        }
+
+        var newObj = {};
+        var hasPropertyDescriptor =
+          Object.defineProperty && Object.getOwnPropertyDescriptor;
+
+        for (var key in obj) {
+          if (Object.prototype.hasOwnProperty.call(obj, key)) {
+            var desc = hasPropertyDescriptor
+              ? Object.getOwnPropertyDescriptor(obj, key)
+              : null;
+
+            if (desc && (desc.get || desc.set)) {
+              Object.defineProperty(newObj, key, desc);
+            } else {
+              newObj[key] = obj[key];
+            }
+          }
+        }
+
+        newObj.default = obj;
+
+        if (cache) {
+          cache.set(obj, newObj);
+        }
+
+        return newObj;
+      }
+
       function defaultHead() {
         var inAmpMode =
           arguments.length > 0 && arguments[0] !== undefined
@@ -352,8 +410,6 @@ Also adds support for deduplicated `key` properties
             });
           });
       }
-
-      var Effect = (0, _sideEffect.default)();
       /**
        * This component injects elements to `<head>` of your page.
        * To avoid duplicated `tags` in `<head>` you can use the `key` property, which will make sure every tag is only rendered once.
@@ -361,28 +417,23 @@ Also adds support for deduplicated `key` properties
 
       function Head(_ref) {
         var { children } = _ref;
+        var ampState = (0, _react.useContext)(_ampContext.AmpStateContext);
+        var headManager = (0, _react.useContext)(
+          _headManagerContext.HeadManagerContext
+        );
         return /*#__PURE__*/ _react.default.createElement(
-          _ampContext.AmpStateContext.Consumer,
-          null,
-          ampState =>
-            /*#__PURE__*/ _react.default.createElement(
-              _headManagerContext.HeadManagerContext.Consumer,
-              null,
-              updateHead =>
-                /*#__PURE__*/ _react.default.createElement(
-                  Effect,
-                  {
-                    reduceComponentsToState: reduceComponents,
-                    handleStateChange: updateHead,
-                    inAmpMode: (0, _amp.isInAmpMode)(ampState)
-                  },
-                  children
-                )
-            )
+          _sideEffect.default,
+          {
+            reduceComponentsToState: reduceComponents,
+            headManager: headManager,
+            inAmpMode: (0, _amp.isInAmpMode)(ampState)
+          },
+          children
         );
-      }
+      } // TODO: Remove in the next major release
+
+      Head.rewind = () => {};
 
-      Head.rewind = Effect.rewind;
       var _default = Head;
       exports.default = _default;
 
@@ -405,7 +456,7 @@ Also adds support for deduplicated `key` properties
             };
       }
 
-      var HeadManagerContext = _react.default.createContext(null);
+      var HeadManagerContext = _react.default.createContext({});
 
       exports.HeadManagerContext = HeadManagerContext;
 
@@ -449,58 +500,43 @@ Also adds support for deduplicated `key` properties
 
       var isServer = false;
 
-      var _default = () => {
-        var mountedInstances = new Set();
-        var state;
+      class _default extends _react.Component {
+        constructor(props) {
+          super(props);
 
-        function emitChange(component) {
-          state = component.props.reduceComponentsToState(
-            [...mountedInstances],
-            component.props
-          );
+          this.emitChange = () => {
+            this.props.headManager.updateHead(
+              this.props.reduceComponentsToState(
+                [...this.props.headManager.mountedInstances],
+                this.props
+              )
+            );
+          };
 
-          if (component.props.handleStateChange) {
-            component.props.handleStateChange(state);
+          if (isServer) {
+            this.props.headManager.mountedInstances.add(this);
+            this.emitChange();
           }
         }
 
-        return class extends _react.Component {
-          // Used when server rendering
-          static rewind() {
-            var recordedState = state;
-            state = undefined;
-            mountedInstances.clear();
-            return recordedState;
-          }
-
-          constructor(props) {
-            super(props);
-
-            if (isServer) {
-              mountedInstances.add(this);
-              emitChange(this);
-            }
-          }
-
-          componentDidMount() {
-            mountedInstances.add(this);
-            emitChange(this);
-          }
+        componentDidMount() {
+          this.props.headManager.mountedInstances.add(this);
+          this.emitChange();
+        }
 
-          componentDidUpdate() {
-            emitChange(this);
-          }
+        componentDidUpdate() {
+          this.emitChange();
+        }
 
-          componentWillUnmount() {
-            mountedInstances.delete(this);
-            emitChange(this);
-          }
+        componentWillUnmount() {
+          this.props.headManager.mountedInstances.delete(this);
+          this.emitChange();
+        }
 
-          render() {
-            return null;
-          }
-        };
-      };
+        render() {
+          return null;
+        }
+      }
 
       exports.default = _default;
Diff for _error.js
@@ -281,7 +281,7 @@
       exports.defaultHead = defaultHead;
       exports["default"] = void 0;
 
-      var _react = _interopRequireDefault(__webpack_require__("q1tI"));
+      var _react = _interopRequireWildcard(__webpack_require__("q1tI"));
 
       var _sideEffect = _interopRequireDefault(__webpack_require__("Xuae"));
 
@@ -299,6 +299,64 @@
             };
       }
 
+      function _getRequireWildcardCache() {
+        if (typeof WeakMap !== "function") return null;
+        var cache = new WeakMap();
+
+        _getRequireWildcardCache = function _getRequireWildcardCache() {
+          return cache;
+        };
+
+        return cache;
+      }
+
+      function _interopRequireWildcard(obj) {
+        if (obj && obj.__esModule) {
+          return obj;
+        }
+
+        if (
+          obj === null ||
+          (typeof obj !== "object" && typeof obj !== "function")
+        ) {
+          return {
+            default: obj
+          };
+        }
+
+        var cache = _getRequireWildcardCache();
+
+        if (cache && cache.has(obj)) {
+          return cache.get(obj);
+        }
+
+        var newObj = {};
+        var hasPropertyDescriptor =
+          Object.defineProperty && Object.getOwnPropertyDescriptor;
+
+        for (var key in obj) {
+          if (Object.prototype.hasOwnProperty.call(obj, key)) {
+            var desc = hasPropertyDescriptor
+              ? Object.getOwnPropertyDescriptor(obj, key)
+              : null;
+
+            if (desc && (desc.get || desc.set)) {
+              Object.defineProperty(newObj, key, desc);
+            } else {
+              newObj[key] = obj[key];
+            }
+          }
+        }
+
+        newObj["default"] = obj;
+
+        if (cache) {
+          cache.set(obj, newObj);
+        }
+
+        return newObj;
+      }
+
       function defaultHead() {
         var inAmpMode =
           arguments.length > 0 && arguments[0] !== undefined
@@ -441,8 +499,6 @@ Also adds support for deduplicated `key` properties
             });
           });
       }
-
-      var Effect = (0, _sideEffect["default"])();
       /**
        * This component injects elements to `<head>` of your page.
        * To avoid duplicated `tags` in `<head>` you can use the `key` property, which will make sure every tag is only rendered once.
@@ -450,30 +506,23 @@ Also adds support for deduplicated `key` properties
 
       function Head(_ref) {
         var children = _ref.children;
+        var ampState = (0, _react.useContext)(_ampContext.AmpStateContext);
+        var headManager = (0, _react.useContext)(
+          _headManagerContext.HeadManagerContext
+        );
         return /*#__PURE__*/ _react["default"].createElement(
-          _ampContext.AmpStateContext.Consumer,
-          null,
-          function(ampState) {
-            return /*#__PURE__*/ _react["default"].createElement(
-              _headManagerContext.HeadManagerContext.Consumer,
-              null,
-              function(updateHead) {
-                return /*#__PURE__*/ _react["default"].createElement(
-                  Effect,
-                  {
-                    reduceComponentsToState: reduceComponents,
-                    handleStateChange: updateHead,
-                    inAmpMode: (0, _amp.isInAmpMode)(ampState)
-                  },
-                  children
-                );
-              }
-            );
-          }
+          _sideEffect["default"],
+          {
+            reduceComponentsToState: reduceComponents,
+            headManager: headManager,
+            inAmpMode: (0, _amp.isInAmpMode)(ampState)
+          },
+          children
         );
-      }
+      } // TODO: Remove in the next major release
+
+      Head.rewind = function() {};
 
-      Head.rewind = Effect.rewind;
       var _default = Head;
       exports["default"] = _default;
 
@@ -519,7 +568,7 @@ Also adds support for deduplicated `key` properties
             };
       }
 
-      var HeadManagerContext = _react["default"].createContext(null);
+      var HeadManagerContext = _react["default"].createContext({});
 
       exports.HeadManagerContext = HeadManagerContext;
 
@@ -677,20 +726,20 @@ Also adds support for deduplicated `key` properties
     /***/ Xuae: /***/ function(module, exports, __webpack_require__) {
       "use strict";
 
-      var _classCallCheck = __webpack_require__("lwsE");
+      var _toConsumableArray = __webpack_require__("RIqP");
 
-      var _assertThisInitialized = __webpack_require__("PJYZ");
+      var _classCallCheck = __webpack_require__("lwsE");
 
       var _createClass = __webpack_require__("W8MJ");
 
+      var _assertThisInitialized = __webpack_require__("PJYZ");
+
       var _inherits = __webpack_require__("7W2i");
 
       var _possibleConstructorReturn = __webpack_require__("a1gu");
 
       var _getPrototypeOf = __webpack_require__("Nsbk");
 
-      var _toConsumableArray = __webpack_require__("RIqP");
-
       function _createSuper(Derived) {
         var hasNativeReflectConstruct = _isNativeReflectConstruct();
         return function _createSuperInternal() {
@@ -727,86 +776,69 @@ Also adds support for deduplicated `key` properties
 
       var isServer = false;
 
-      var _default = function _default() {
-        var mountedInstances = new Set();
-        var state;
+      var _default = /*#__PURE__*/ (function(_react$Component) {
+        _inherits(_default, _react$Component);
 
-        function emitChange(component) {
-          state = component.props.reduceComponentsToState(
-            _toConsumableArray(mountedInstances),
-            component.props
-          );
+        var _super = _createSuper(_default);
 
-          if (component.props.handleStateChange) {
-            component.props.handleStateChange(state);
-          }
-        }
+        function _default(props) {
+          var _this;
 
-        return /*#__PURE__*/ (function(_react$Component) {
-          _inherits(_class, _react$Component);
+          _classCallCheck(this, _default);
 
-          var _super = _createSuper(_class);
+          _this = _super.call(this, props);
 
-          _createClass(_class, null, [
-            {
-              key: "rewind",
-              // Used when server rendering
-              value: function rewind() {
-                var recordedState = state;
-                state = undefined;
-                mountedInstances.clear();
-                return recordedState;
-              }
-            }
-          ]);
+          _this.emitChange = function() {
+            _this.props.headManager.updateHead(
+              _this.props.reduceComponentsToState(
+                _toConsumableArray(_this.props.headManager.mountedInstances),
+                _this.props
+              )
+            );
+          };
 
-          function _class(props) {
-            var _this;
+          if (isServer) {
+            _this.props.headManager.mountedInstances.add(
+              _assertThisInitialized(_this)
+            );
 
-            _classCallCheck(this, _class);
+            _this.emitChange();
+          }
 
-            _this = _super.call(this, props);
+          return _this;
+        }
 
-            if (isServer) {
-              mountedInstances.add(_assertThisInitialized(_this));
-              emitChange(_assertThisInitialized(_this));
+        _createClass(_default, [
+          {
+            key: "componentDidMount",
+            value: function componentDidMount() {
+              this.props.headManager.mountedInstances.add(this);
+              this.emitChange();
             }
-
-            return _this;
-          }
-
-          _createClass(_class, [
-            {
-              key: "componentDidMount",
-              value: function componentDidMount() {
-                mountedInstances.add(this);
-                emitChange(this);
-              }
-            },
-            {
-              key: "componentDidUpdate",
-              value: function componentDidUpdate() {
-                emitChange(this);
-              }
-            },
-            {
-              key: "componentWillUnmount",
-              value: function componentWillUnmount() {
-                mountedInstances["delete"](this);
-                emitChange(this);
-              }
-            },
-            {
-              key: "render",
-              value: function render() {
-                return null;
-              }
+          },
+          {
+            key: "componentDidUpdate",
+            value: function componentDidUpdate() {
+              this.emitChange();
             }
-          ]);
+          },
+          {
+            key: "componentWillUnmount",
+            value: function componentWillUnmount() {
+              this.props.headManager.mountedInstances["delete"](this);
+              this.emitChange();
+            }
+          },
+          {
+            key: "render",
+            value: function render() {
+              return null;
+            }
+          }
+        ]);
 
-          return _class;
-        })(_react.Component);
-      };
+        return _default;
+      })(_react.Component);
 
       exports["default"] = _default;
Diff for _buildManifest.js
@@ -1,6 +1,6 @@
 self.__BUILD_MANIFEST = {
   "/": ["static\u002F8f6ec52978e4ed685749\u002Fpages\u002Findex.js"],
-  "/_error": ["static\u002F0dd45ce0aa0f4454606b\u002Fpages\u002F_error.js"],
+  "/_error": ["static\u002F280ae3949913ae3eca18\u002Fpages\u002F_error.js"],
   "/hooks": ["static\u002F701db499b372d8b4ad8a\u002Fpages\u002Fhooks.js"],
   "/link": ["static\u002Fe826d21ad4f09aa9e68e\u002Fpages\u002Flink.js"],
   "/routerDirect": [
Diff for _buildManifest.module.js
@@ -1,7 +1,7 @@
 self.__BUILD_MANIFEST = {
   "/": ["static\u002F617084c2156e7a4c3a6e\u002Fpages\u002Findex.module.js"],
   "/_error": [
-    "static\u002F044e777feb8a752b7656\u002Fpages\u002F_error.module.js"
+    "static\u002F4945a630f79d7fe38292\u002Fpages\u002F_error.module.js"
   ],
   "/hooks": [
     "static\u002F680ac2d033b0bc870c3a\u002Fpages\u002Fhooks.module.js"
Diff for main-HASH.js
@@ -129,30 +129,35 @@
 
       function initHeadManager() {
         var updatePromise = null;
-        return function(head) {
-          var promise = (updatePromise = Promise.resolve().then(function() {
-            if (promise !== updatePromise) return;
-            updatePromise = null;
-            var tags = {};
-            head.forEach(function(h) {
-              var components = tags[h.type] || [];
-              components.push(h);
-              tags[h.type] = components;
-            });
-            var titleComponent = tags.title ? tags.title[0] : null;
-            var title = "";
+        return {
+          mountedInstances: new Set(),
+          updateHead: function updateHead(head) {
+            var promise = (updatePromise = Promise.resolve().then(function() {
+              if (promise !== updatePromise) return;
+              updatePromise = null;
+              var tags = {};
+              head.forEach(function(h) {
+                var components = tags[h.type] || [];
+                components.push(h);
+                tags[h.type] = components;
+              });
+              var titleComponent = tags.title ? tags.title[0] : null;
+              var title = "";
 
-            if (titleComponent) {
-              var children = titleComponent.props.children;
-              title =
-                typeof children === "string" ? children : children.join("");
-            }
+              if (titleComponent) {
+                var children = titleComponent.props.children;
+                title =
+                  typeof children === "string" ? children : children.join("");
+              }
 
-            if (title !== document.title) document.title = title;
-            ["meta", "base", "link", "style", "script"].forEach(function(type) {
-              updateElements(type, tags[type] || []);
-            });
-          }));
+              if (title !== document.title) document.title = title;
+              ["meta", "base", "link", "style", "script"].forEach(function(
+                type
+              ) {
+                updateElements(type, tags[type] || []);
+              });
+            }));
+          }
         };
       }
 
@@ -175,7 +180,7 @@
             };
       }
 
-      var HeadManagerContext = _react["default"].createContext(null);
+      var HeadManagerContext = _react["default"].createContext({});
 
       exports.HeadManagerContext = HeadManagerContext;
 
@@ -333,7 +338,7 @@
 
       window.__NEXT_P = [];
       window.__NEXT_P.push = register;
-      var updateHead = (0, _headManager["default"])();
+      var headManager = (0, _headManager["default"])();
       var appElement = document.getElementById("__next");
       var lastAppProps;
 
@@ -899,7 +904,7 @@
             /*#__PURE__*/ _react["default"].createElement(
               _headManagerContext.HeadManagerContext.Provider,
               {
-                value: updateHead
+                value: headManager
               },
               children
             )
Diff for main-HASH.module.js
@@ -96,30 +96,33 @@
 
       function initHeadManager() {
         var updatePromise = null;
-        return head => {
-          var promise = (updatePromise = Promise.resolve().then(() => {
-            if (promise !== updatePromise) return;
-            updatePromise = null;
-            var tags = {};
-            head.forEach(h => {
-              var components = tags[h.type] || [];
-              components.push(h);
-              tags[h.type] = components;
-            });
-            var titleComponent = tags.title ? tags.title[0] : null;
-            var title = "";
+        return {
+          mountedInstances: new Set(),
+          updateHead: head => {
+            var promise = (updatePromise = Promise.resolve().then(() => {
+              if (promise !== updatePromise) return;
+              updatePromise = null;
+              var tags = {};
+              head.forEach(h => {
+                var components = tags[h.type] || [];
+                components.push(h);
+                tags[h.type] = components;
+              });
+              var titleComponent = tags.title ? tags.title[0] : null;
+              var title = "";
 
-            if (titleComponent) {
-              var { children } = titleComponent.props;
-              title =
-                typeof children === "string" ? children : children.join("");
-            }
+              if (titleComponent) {
+                var { children } = titleComponent.props;
+                title =
+                  typeof children === "string" ? children : children.join("");
+              }
 
-            if (title !== document.title) document.title = title;
-            ["meta", "base", "link", "style", "script"].forEach(type => {
-              updateElements(type, tags[type] || []);
-            });
-          }));
+              if (title !== document.title) document.title = title;
+              ["meta", "base", "link", "style", "script"].forEach(type => {
+                updateElements(type, tags[type] || []);
+              });
+            }));
+          }
         };
       }
 
@@ -142,7 +145,7 @@
             };
       }
 
-      var HeadManagerContext = _react.default.createContext(null);
+      var HeadManagerContext = _react.default.createContext({});
 
       exports.HeadManagerContext = HeadManagerContext;
 
@@ -248,7 +251,7 @@
 
       window.__NEXT_P = [];
       window.__NEXT_P.push = register;
-      var updateHead = (0, _headManager.default)();
+      var headManager = (0, _headManager.default)();
       var appElement = document.getElementById("__next");
       var lastAppProps;
       var lastRenderReject;
@@ -642,7 +645,7 @@
             /*#__PURE__*/ _react.default.createElement(
               _headManagerContext.HeadManagerContext.Provider,
               {
-                value: updateHead
+                value: headManager
               },
               children
             )
Diff for index.html
@@ -6,7 +6,7 @@
     <meta name="next-head-count" content="2" />
     <link
       rel="preload"
-      href="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      href="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -81,13 +81,13 @@
       src="/_next/static/runtime/polyfills-eaf5488e20ec921d713f.js"
     ></script>
     <script
-      src="/_next/static/runtime/main-0d66d3e4991e946c74e4.js"
+      src="/_next/static/runtime/main-5645e84ad489a13ad929.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      src="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -6,7 +6,7 @@
     <meta name="next-head-count" content="2" />
     <link
       rel="preload"
-      href="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      href="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -86,13 +86,13 @@
       src="/_next/static/runtime/polyfills-eaf5488e20ec921d713f.js"
     ></script>
     <script
-      src="/_next/static/runtime/main-0d66d3e4991e946c74e4.js"
+      src="/_next/static/runtime/main-5645e84ad489a13ad929.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      src="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -6,7 +6,7 @@
     <meta name="next-head-count" content="2" />
     <link
       rel="preload"
-      href="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      href="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -81,13 +81,13 @@
       src="/_next/static/runtime/polyfills-eaf5488e20ec921d713f.js"
     ></script>
     <script
-      src="/_next/static/runtime/main-0d66d3e4991e946c74e4.js"
+      src="/_next/static/runtime/main-5645e84ad489a13ad929.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/runtime/main-9cadc10c0e9845b278fe.module.js"
+      src="/_next/static/runtime/main-8d80041349de450e5b26.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
buildDuration 13.6s 13.4s -184ms
nodeModulesSize 64.9 MB 64.9 MB -2.5 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
main-HASH.js gzip 6.49 kB 6.51 kB ⚠️ +18 B
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..0538.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.9 kB 56.9 kB ⚠️ +18 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
main-HASH.module.js gzip 5.58 kB 5.6 kB ⚠️ +20 B
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.4 kB 52.4 kB ⚠️ +20 B
Legacy Client Bundles (polyfills)
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
hooks.js gzip 881 B 881 B
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.37 kB ⚠️ +123 B
Overall change 8.22 kB 8.34 kB ⚠️ +123 B
Client Pages Modern Overall increase ⚠️
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
index.module.js gzip 223 B 223 B
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
_error.module.js gzip 2.04 kB 2.21 kB ⚠️ +167 B
hooks.module.js gzip 383 B 383 B
link.module.js gzip 1.52 kB 1.52 kB
_app.module.js gzip 604 B 604 B
Overall change 5.33 kB 5.49 kB ⚠️ +167 B
Client Build Manifests Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
_buildManifest.js gzip 270 B 270 B
_buildManife..dule.js gzip 275 B 274 B -1 B
Overall change 545 B 544 B -1 B
Serverless bundles Overall decrease ✓
vercel/next.js canary timneutkens/next.js fix/remove-rewind Change
_error.js 875 kB 875 kB -122 B
404.html 4.17 kB 4.17 kB
hooks.html 3.79 kB 3.79 kB
index.js 875 kB 875 kB -122 B
link.js 913 kB 913 kB -122 B
routerDirect.js 905 kB 905 kB -122 B
withRouter.js 905 kB 905 kB -122 B
Overall change 4.48 MB 4.48 MB -610 B

Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

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

LGTM

@kodiakhq kodiakhq bot merged commit 89fffa6 into vercel:canary Jun 11, 2020
@timneutkens timneutkens deleted the fix/remove-rewind branch June 12, 2020 08:27
darshkpatel pushed a commit to MLH-Fellowship/next.js that referenced this pull request Jun 12, 2020
rokinsky pushed a commit to rokinsky/next.js that referenced this pull request Jul 11, 2020
@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
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.

Documentation about Head.rewind
2 participants