Skip to content

Commit

Permalink
fix: handle jsxspreadattribute in inline-script-id eslint rule (#32421)
Browse files Browse the repository at this point in the history
fixes #32178

the `inline-script-id` eslint rule crashed when encountering a `JSXSpreadAttribute`. this pr fixes that, and also handles `id` being passed via the spreaded object.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] ~~Integration~~ Unit tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
  • Loading branch information
stefanprobst committed Feb 2, 2022
1 parent abae663 commit 49afcd4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/eslint-plugin-next/lib/rules/inline-script-id.js
Expand Up @@ -27,15 +27,22 @@ module.exports = {
return
}

const attributes = node.openingElement.attributes
const attributeNames = new Set()
node.openingElement.attributes.forEach((attribute) => {
if (attribute.type === 'JSXAttribute') {
attributeNames.add(attribute.name.name)
} else if (attribute.type === 'JSXSpreadAttribute') {
attribute.argument.properties.forEach((property) => {
attributeNames.add(property.key.name)
})
}
})

if (
node.children.length > 0 ||
attributes.some(
(attribute) => attribute.name.name === 'dangerouslySetInnerHTML'
)
attributeNames.has('dangerouslySetInnerHTML')
) {
if (!attributes.some((attribute) => attribute.name.name === 'id')) {
if (!attributeNames.has('id')) {
context.report({
node,
message:
Expand Down
22 changes: 22 additions & 0 deletions test/unit/eslint-plugin-next/inline-script-id.test.ts
Expand Up @@ -76,6 +76,28 @@ ruleTester.run('inline-script-id', rule, {
)
}`,
},
{
code: `import Script from 'next/script';
export default function TestPage() {
return (
<Script {...{ strategy: "lazyOnload" }} id={"test-script"}>
{\`console.log('Hello world');\`}
</Script>
)
}`,
},
{
code: `import Script from 'next/script';
export default function TestPage() {
return (
<Script {...{ strategy: "lazyOnload", id: "test-script" }}>
{\`console.log('Hello world');\`}
</Script>
)
}`,
},
],
invalid: [
{
Expand Down

1 comment on commit 49afcd4

@ijjk
Copy link
Member

@ijjk ijjk commented on 49afcd4 Feb 2, 2022

Choose a reason for hiding this comment

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

Stats from current release

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
buildDuration 15.3s 15.3s -3ms
buildDurationCached 3.7s 3.8s ⚠️ +38ms
nodeModulesSize 359 MB 359 MB ⚠️ +10.4 kB
Page Load Tests Overall increase ✓
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
/ failed reqs 0 0
/ total time (seconds) 3.761 3.541 -0.22
/ avg req/sec 664.78 706.06 +41.28
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.866 1.683 -0.18
/error-in-render avg req/sec 1339.69 1485.42 +145.73
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
450.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.2 kB 42.2 kB
main-HASH.js gzip 27.2 kB 27.3 kB ⚠️ +140 B
webpack-HASH.js gzip 1.44 kB 1.44 kB
Overall change 71 kB 71.2 kB ⚠️ +140 B
Legacy Client Bundles (polyfills)
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages Overall decrease ✓
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
_app-HASH.js gzip 1.37 kB 1.37 kB
_error-HASH.js gzip 194 B 194 B
amp-HASH.js gzip 312 B 312 B
css-HASH.js gzip 326 B 326 B
dynamic-HASH.js gzip 2.37 kB 2.37 kB
head-HASH.js gzip 350 B 350 B
hooks-HASH.js gzip 919 B 919 B
image-HASH.js gzip 4.94 kB 4.94 kB -1 B
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 2.19 kB 2.19 kB
routerDirect..HASH.js gzip 321 B 321 B
script-HASH.js gzip 383 B 383 B
withRouter-HASH.js gzip 318 B 318 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 14.4 kB 14.3 kB -1 B
Client Build Manifests
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
_buildManifest.js gzip 459 B 459 B
Overall change 459 B 459 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
index.html gzip 530 B 531 B ⚠️ +1 B
link.html gzip 543 B 545 B ⚠️ +2 B
withRouter.html gzip 525 B 526 B ⚠️ +1 B
Overall change 1.6 kB 1.6 kB ⚠️ +4 B

Diffs

Diff for _buildManifest.js
@@ -12,7 +12,7 @@ self.__BUILD_MANIFEST = {
   ],
   "/head": ["static\u002Fchunks\u002Fpages\u002Fhead-7100d3b2a548f0e4.js"],
   "/hooks": ["static\u002Fchunks\u002Fpages\u002Fhooks-538d621a0e670391.js"],
-  "/image": ["static\u002Fchunks\u002Fpages\u002Fimage-53463827ccaef972.js"],
+  "/image": ["static\u002Fchunks\u002Fpages\u002Fimage-f97943edf7ae3dd3.js"],
   "/link": ["static\u002Fchunks\u002Fpages\u002Flink-f0a2c3bb0706d8b2.js"],
   "/routerDirect": [
     "static\u002Fchunks\u002Fpages\u002FrouterDirect-76232dd6bc335a24.js"
Diff for image-HASH.js
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/image",
         function() {
-          return __webpack_require__(5924);
+          return __webpack_require__(3155);
         }
       ]);
       if (false) {
@@ -1087,7 +1087,7 @@
       /***/
     },
 
-    /***/ 5924: /***/ function(
+    /***/ 3155: /***/ function(
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
Diff for main-HASH.js
@@ -474,8 +474,8 @@
       var _routeAnnouncer = __webpack_require__(8982);
       var _router1 = __webpack_require__(387);
       var _isError = __webpack_require__(676);
-      var _vitals = __webpack_require__(7813);
-      var _refresh = __webpack_require__(7739);
+      var _vitals = __webpack_require__(5834);
+      var _refresh = __webpack_require__(9831);
       function asyncGeneratorStep(
         gen,
         resolve,
@@ -628,7 +628,7 @@
         document.getElementById("__NEXT_DATA__").textContent
       );
       window.__NEXT_DATA__ = data;
-      var version = "12.0.10";
+      var version = "12.0.11-canary.3";
       exports.version = version;
       var looseToArray = function(input) {
         return [].slice.call(input);
@@ -980,16 +980,15 @@
                         props: hydrateProps,
                         err: initialErr
                       };
-                      if (false) {
+                      if (!opts.beforeRender) {
+                        _ctx.next = 42;
+                        break;
                       }
+                      _ctx.next = 42;
+                      return opts.beforeRender();
+                    case 42:
                       render(renderCtx);
-                      return _ctx.abrupt("return", emitter);
-                    case 44:
-                      return _ctx.abrupt("return", {
-                        emitter: emitter,
-                        renderCtx: renderCtx
-                      });
-                    case 45:
+                    case 43:
                     case "end":
                       return _ctx.stop();
                   }
@@ -1464,6 +1463,7 @@
         // don't cause any hydration delay:
         _react.default.useEffect(function() {
           (0, _performanceRelayer).default(onPerfEntry);
+          (0, _vitals).flushBufferedVitalsMetrics();
         }, []);
         return children;
       }
@@ -2768,28 +2768,6 @@
       /***/
     },
 
-    /***/ 7739: /***/ function(
-      __unused_webpack_module,
-      exports,
-      __webpack_require__
-    ) {
-      "use strict";
-
-      Object.defineProperty(exports, "__esModule", {
-        value: true
-      });
-      exports.useRefreshRoot = useRefreshRoot;
-      exports.RefreshContext = void 0;
-      var _react = __webpack_require__(7294);
-      var RefreshContext = (0, _react).createContext(function(_) {});
-      exports.RefreshContext = RefreshContext;
-      function useRefreshRoot() {
-        return (0, _react).useContext(RefreshContext);
-      } //# sourceMappingURL=refresh.js.map
-
-      /***/
-    },
-
     /***/ 699: /***/ function(
       __unused_webpack_module,
       exports,
@@ -3146,7 +3124,7 @@
       /***/
     },
 
-    /***/ 7813: /***/ function(
+    /***/ 9831: /***/ function(
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -3156,13 +3134,45 @@
       Object.defineProperty(exports, "__esModule", {
         value: true
       });
+      exports.useRefreshRoot = useRefreshRoot;
+      exports.RefreshContext = void 0;
+      var _react = __webpack_require__(7294);
+      var RefreshContext = (0, _react).createContext(function(_) {});
+      exports.RefreshContext = RefreshContext;
+      function useRefreshRoot() {
+        return (0, _react).useContext(RefreshContext);
+      } //# sourceMappingURL=refresh.js.map
+
+      /***/
+    },
+
+    /***/ 5834: /***/ function(
+      __unused_webpack_module,
+      exports,
+      __webpack_require__
+    ) {
+      "use strict";
+
+      Object.defineProperty(exports, "__esModule", {
+        value: true
+      });
+      exports.getBufferedVitalsMetrics = getBufferedVitalsMetrics;
+      exports.flushBufferedVitalsMetrics = flushBufferedVitalsMetrics;
       exports.trackWebVitalMetric = trackWebVitalMetric;
       exports.useWebVitalsReport = useWebVitalsReport;
       exports.webVitalsCallbacks = void 0;
       var _react = __webpack_require__(7294);
       var webVitalsCallbacks = new Set();
       exports.webVitalsCallbacks = webVitalsCallbacks;
+      var flushed = false;
       var metrics = [];
+      function getBufferedVitalsMetrics() {
+        return metrics;
+      }
+      function flushBufferedVitalsMetrics() {
+        flushed = true;
+        metrics.length = 0;
+      }
       function trackWebVitalMetric(metric) {
         metrics.push(metric);
         webVitalsCallbacks.forEach(function(callback) {
@@ -3171,6 +3181,8 @@
       }
       function useWebVitalsReport(callback) {
         var metricIndexRef = (0, _react).useRef(0);
+        if (false) {
+        }
         (0, _react).useEffect(
           function() {
             // Flush calculated metrics
@@ -5052,29 +5064,65 @@
                                   delBasePath(pathname)
                                 )
                               : pathname;
-                            if (shouldResolveHref && pathname !== "/_error") {
-                              options._shouldResolveHref = true;
-                              if (false) {
-                              } else {
-                                parsed.pathname = resolveDynamicRoute(
-                                  pathname,
-                                  pages
-                                );
-                                if (parsed.pathname !== pathname) {
-                                  pathname = parsed.pathname;
-                                  parsed.pathname = addBasePath(pathname);
-                                  url = (0, _utils).formatWithValidation(
-                                    parsed
-                                  );
-                                }
-                              }
+                            if (
+                              !(shouldResolveHref && pathname !== "/_error")
+                            ) {
+                              _ctx.next = 69;
+                              break;
+                            }
+                            options._shouldResolveHref = true;
+                            if (true) {
+                              _ctx.next = 68;
+                              break;
+                            }
+                            rewritesResult = (0, _resolveRewrites).default(
+                              addBasePath(addLocale(cleanedAs, _this.locale)),
+                              pages,
+                              rewrites,
+                              query,
+                              function(p) {
+                                return resolveDynamicRoute(p, pages);
+                              },
+                              _this.locales
+                            );
+                            if (!rewritesResult.externalDest) {
+                              _ctx.next = 64;
+                              break;
+                            }
+                            location.href = as;
+                            return _ctx.abrupt("return", true);
+                          case 64:
+                            resolvedAs = rewritesResult.asPath;
+                            if (
+                              rewritesResult.matchedPage &&
+                              rewritesResult.resolvedHref
+                            ) {
+                              // if this directly matches a page we need to update the href to
+                              // allow the correct page chunk to be loaded
+                              pathname = rewritesResult.resolvedHref;
+                              parsed.pathname = addBasePath(pathname);
+                              url = (0, _utils).formatWithValidation(parsed);
+                            }
+                            _ctx.next = 69;
+                            break;
+                          case 68: {
+                            parsed.pathname = resolveDynamicRoute(
+                              pathname,
+                              pages
+                            );
+                            if (parsed.pathname !== pathname) {
+                              pathname = parsed.pathname;
+                              parsed.pathname = addBasePath(pathname);
+                              url = (0, _utils).formatWithValidation(parsed);
                             }
+                          }
+                          case 69:
                             if (isLocalURL(as)) {
-                              _ctx.next = 63;
+                              _ctx.next = 74;
                               break;
                             }
                             if (true) {
-                              _ctx.next = 61;
+                              _ctx.next = 72;
                               break;
                             }
                             throw new Error(
@@ -5086,10 +5134,10 @@
                                 ) +
                                 "\nSee more info: https://nextjs.org/docs/messages/invalid-relative-url-external-as"
                             );
-                          case 61:
+                          case 72:
                             window.location.href = as;
                             return _ctx.abrupt("return", false);
-                          case 63:
+                          case 74:
                             resolvedAs = delLocale(
                               delBasePath(resolvedAs),
                               _this.locale
@@ -5105,10 +5153,10 @@
                                 )
                               )
                             ) {
-                              _ctx.next = 84;
+                              _ctx.next = 95;
                               break;
                             }
-                            _ctx.next = 67;
+                            _ctx.next = 78;
                             return _this._preflightRequest({
                               as: as,
                               cache: "production" === "production",
@@ -5116,10 +5164,10 @@
                               pathname: pathname,
                               query: query
                             });
-                          case 67:
+                          case 78:
                             effect = _ctx.sent;
                             if (!(effect.type === "rewrite")) {
-                              _ctx.next = 72;
+                              _ctx.next = 83;
                               break;
                             }
                             {
@@ -5133,11 +5181,11 @@
                               parsed.pathname = effect.resolvedHref;
                               url = (0, _utils).formatWithValidation(parsed);
                             }
-                            _ctx.next = 84;
+                            _ctx.next = 95;
                             break;
-                          case 72:
+                          case 83:
                             if (!(effect.type === "redirect" && effect.newAs)) {
-                              _ctx.next = 76;
+                              _ctx.next = 87;
                               break;
                             }
                             return _ctx.abrupt(
@@ -5149,13 +5197,13 @@
                                 options
                               )
                             );
-                          case 76:
+                          case 87:
                             if (
                               !(
                                 effect.type === "redirect" && effect.destination
                               )
                             ) {
-                              _ctx.next = 81;
+                              _ctx.next = 92;
                               break;
                             }
                             window.location.href = effect.destination;
@@ -5163,14 +5211,14 @@
                               "return",
                               new Promise(function() {})
                             );
-                          case 81:
+                          case 92:
                             if (
                               !(
                                 effect.type === "refresh" &&
                                 as !== window.location.pathname
                               )
                             ) {
-                              _ctx.next = 84;
+                              _ctx.next = 95;
                               break;
                             }
                             window.location.href = as;
@@ -5178,13 +5226,13 @@
                               "return",
                               new Promise(function() {})
                             );
-                          case 84:
+                          case 95:
                             route = (0,
                             _normalizeTrailingSlash).removePathTrailingSlash(
                               pathname
                             );
                             if (!(0, _isDynamic).isDynamicRoute(route)) {
-                              _ctx.next = 100;
+                              _ctx.next = 111;
                               break;
                             }
                             parsedAs1 = (0, _parseRelativeUrl).parseRelativeUrl(
@@ -5205,7 +5253,7 @@
                                 (shouldInterpolate && !interpolatedAs.result)
                               )
                             ) {
-                              _ctx.next = 99;
+                              _ctx.next = 110;
                               break;
                             }
                             missingParams = Object.keys(
@@ -5214,7 +5262,7 @@
                               return !query[param];
                             });
                             if (!(missingParams.length > 0)) {
-                              _ctx.next = 97;
+                              _ctx.next = 108;
                               break;
                             }
                             if (false) {
@@ -5242,10 +5290,10 @@
                                     : "incompatible-href-as"
                                 )
                             );
-                          case 97:
-                            _ctx.next = 100;
+                          case 108:
+                            _ctx.next = 111;
                             break;
-                          case 99:
+                          case 110:
                             if (shouldInterpolate) {
                               as = (0, _utils).formatWithValidation(
                                 Object.assign({}, parsedAs1, {
@@ -5260,14 +5308,14 @@
                               // Merge params into `query`, overwriting any specified in search
                               Object.assign(query, routeMatch);
                             }
-                          case 100:
+                          case 111:
                             Router.events.emit(
                               "routeChangeStart",
                               as,
                               routeProps
                             );
-                            _ctx.prev = 101;
-                            _ctx.next = 105;
+                            _ctx.prev = 112;
+                            _ctx.next = 116;
                             return _this.getRouteInfo(
                               route,
                               pathname,
@@ -5276,20 +5324,20 @@
                               resolvedAs,
                               routeProps
                             );
-                          case 105:
+                          case 116:
                             routeInfo = _ctx.sent;
                             (error = routeInfo.error),
                               (props = routeInfo.props),
                               (__N_SSG = routeInfo.__N_SSG),
                               (__N_SSP = routeInfo.__N_SSP);
                             if (!((__N_SSG || __N_SSP) && props)) {
-                              _ctx.next = 132;
+                              _ctx.next = 143;
                               break;
                             }
                             if (
                               !(props.pageProps && props.pageProps.__N_REDIRECT)
                             ) {
-                              _ctx.next = 117;
+                              _ctx.next = 128;
                               break;
                             }
                             destination = props.pageProps.__N_REDIRECT;
@@ -5299,7 +5347,7 @@
                                 props.pageProps.__N_REDIRECT_BASE_PATH !== false
                               )
                             ) {
-                              _ctx.next = 115;
+                              _ctx.next = 126;
                               break;
                             }
                             parsedHref = (0,
@@ -5319,31 +5367,31 @@
                               "return",
                               _this.change(method, newUrl, newAs, options)
                             );
-                          case 115:
+                          case 126:
                             window.location.href = destination;
                             return _ctx.abrupt(
                               "return",
                               new Promise(function() {})
                             );
-                          case 117:
+                          case 128:
                             _this.isPreview = !!props.__N_PREVIEW;
                             if (!(props.notFound === SSG_DATA_NOT_FOUND)) {
-                              _ctx.next = 132;
+                              _ctx.next = 143;
                               break;
                             }
-                            _ctx.prev = 120;
-                            _ctx.next = 123;
+                            _ctx.prev = 131;
+                            _ctx.next = 134;
                             return _this.fetchComponent("/404");
-                          case 123:
+                          case 134:
                             notFoundRoute = "/404";
-                            _ctx.next = 129;
+                            _ctx.next = 140;
                             break;
-                          case 126:
-                            _ctx.prev = 126;
-                            _ctx.t3 = _ctx["catch"](120);
+                          case 137:
+                            _ctx.prev = 137;
+                            _ctx.t3 = _ctx["catch"](131);
                             notFoundRoute = "/_error";
-                          case 129:
-                            _ctx.next = 131;
+                          case 140:
+                            _ctx.next = 142;
                             return _this.getRouteInfo(
                               notFoundRoute,
                               notFoundRoute,
@@ -5354,9 +5402,9 @@
                                 shallow: false
                               }
                             );
-                          case 131:
+                          case 142:
                             routeInfo = _ctx.sent;
-                          case 132:
+                          case 143:
                             Router.events.emit(
                               "beforeHistoryChange",
                               as,
@@ -5394,7 +5442,7 @@
                                   y: 0
                                 }
                               : null;
-                            _ctx.next = 141;
+                            _ctx.next = 152;
                             return _this
                               .set(
                                 route,
@@ -5410,9 +5458,9 @@
                                 if (e.cancelled) error = error || e;
                                 else throw e;
                               });
-                          case 141:
+                          case 152:
                             if (!error) {
-                              _ctx.next = 144;
+                              _ctx.next = 155;
                               break;
                             }
                             Router.events.emit(
@@ -5422,7 +5470,7 @@
                               routeProps
                             );
                             throw error;
-                          case 144:
+                          case 155:
                             if (false) {
                             }
                             Router.events.emit(
@@ -5431,22 +5479,22 @@
                               routeProps
                             );
                             return _ctx.abrupt("return", true);
-                          case 149:
-                            _ctx.prev = 149;
-                            _ctx.t4 = _ctx["catch"](101);
+                          case 160:
+                            _ctx.prev = 160;
+                            _ctx.t4 = _ctx["catch"](112);
                             if (
                               !(
                                 (0, _isError).default(_ctx.t4) &&
                                 _ctx.t4.cancelled
                               )
                             ) {
-                              _ctx.next = 153;
+                              _ctx.next = 164;
                               break;
                             }
                             return _ctx.abrupt("return", false);
-                          case 153:
+                          case 164:
                             throw _ctx.t4;
-                          case 154:
+                          case 165:
                           case "end":
                             return _ctx.stop();
                         }
@@ -5455,8 +5503,8 @@
                     null,
                     [
                       [38, 50],
-                      [101, 149],
-                      [120, 126]
+                      [112, 160],
+                      [131, 137]
                     ]
                   );
                 })
@@ -5932,7 +5980,7 @@
                           pages = _ctx.sent;
                           resolvedAs = asPath;
                           if (true) {
-                            _ctx.next = 20;
+                            _ctx.next = 22;
                             break;
                           }
                           _ctx.next = 12;
@@ -5951,6 +5999,12 @@
                             },
                             _this.locales
                           );
+                          if (!rewritesResult.externalDest) {
+                            _ctx.next = 18;
+                            break;
+                          }
+                          return _ctx.abrupt("return");
+                        case 18:
                           resolvedAs = delLocale(
                             delBasePath(rewritesResult.asPath),
                             _this.locale
@@ -5965,9 +6019,9 @@
                             parsed.pathname = pathname;
                             url = (0, _utils).formatWithValidation(parsed);
                           }
-                          _ctx.next = 21;
+                          _ctx.next = 23;
                           break;
-                        case 20: {
+                        case 22: {
                           parsed.pathname = resolveDynamicRoute(
                             parsed.pathname,
                             pages
@@ -5978,14 +6032,14 @@
                             url = (0, _utils).formatWithValidation(parsed);
                           }
                         }
-                        case 21:
+                        case 23:
                           if (true) {
-                            _ctx.next = 23;
+                            _ctx.next = 25;
                             break;
                           }
                           return _ctx.abrupt("return");
-                        case 23:
-                          _ctx.next = 25;
+                        case 25:
+                          _ctx.next = 27;
                           return _this._preflightRequest({
                             as: addBasePath(asPath),
                             cache: true,
@@ -5993,7 +6047,7 @@
                             pathname: pathname,
                             query: query
                           });
-                        case 25:
+                        case 27:
                           effects = _ctx.sent;
                           if (effects.type === "rewrite") {
                             parsed.pathname = effects.resolvedHref;
@@ -6010,7 +6064,7 @@
                           _normalizeTrailingSlash).removePathTrailingSlash(
                             pathname
                           );
-                          _ctx.next = 30;
+                          _ctx.next = 32;
                           return Promise.all([
                             _this.pageLoader
                               ._isSsg(route)
@@ -6037,7 +6091,7 @@
                               options.priority ? "loadPage" : "prefetch"
                             ](route)
                           ]);
-                        case 30:
+                        case 32:
                         case "end":
                           return _ctx.stop();
                       }
Diff for index.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-c6fc133fe313f8ea.js"
+      src="/_next/static/chunks/main-4a361f38a90cd320.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-c6fc133fe313f8ea.js"
+      src="/_next/static/chunks/main-4a361f38a90cd320.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-c6fc133fe313f8ea.js"
+      src="/_next/static/chunks/main-4a361f38a90cd320.js"
       defer=""
     ></script>
     <script

Default Build with SWC (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
buildDuration 18.9s 19s ⚠️ +169ms
buildDurationCached 3.8s 3.8s ⚠️ +73ms
nodeModulesSize 359 MB 359 MB ⚠️ +10.4 kB
Page Load Tests Overall increase ✓
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
/ failed reqs 0 0
/ total time (seconds) 3.525 3.551 ⚠️ +0.03
/ avg req/sec 709.2 704.06 ⚠️ -5.14
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.743 1.66 -0.08
/error-in-render avg req/sec 1434.27 1505.87 +71.6
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
450.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.3 kB 42.3 kB
main-HASH.js gzip 27.3 kB 27.5 kB ⚠️ +140 B
webpack-HASH.js gzip 1.44 kB 1.44 kB
Overall change 71.3 kB 71.4 kB ⚠️ +140 B
Legacy Client Bundles (polyfills)
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages Overall decrease ✓
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
_app-HASH.js gzip 1.35 kB 1.35 kB
_error-HASH.js gzip 180 B 180 B
amp-HASH.js gzip 305 B 305 B
css-HASH.js gzip 321 B 321 B
dynamic-HASH.js gzip 2.36 kB 2.36 kB
head-HASH.js gzip 342 B 342 B
hooks-HASH.js gzip 911 B 911 B
image-HASH.js gzip 4.98 kB 4.98 kB -2 B
index-HASH.js gzip 256 B 256 B
link-HASH.js gzip 2.21 kB 2.21 kB
routerDirect..HASH.js gzip 314 B 314 B
script-HASH.js gzip 375 B 375 B
withRouter-HASH.js gzip 309 B 309 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 14.3 kB 14.3 kB -2 B
Client Build Manifests
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
_buildManifest.js gzip 458 B 458 B
Overall change 458 B 458 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary v12.0.10 vercel/next.js refs/heads/canary Change
index.html gzip 530 B 530 B
link.html gzip 543 B 542 B -1 B
withRouter.html gzip 525 B 525 B
Overall change 1.6 kB 1.6 kB -1 B

Diffs

Diff for _buildManifest.js
@@ -12,7 +12,7 @@ self.__BUILD_MANIFEST = {
   ],
   "/head": ["static\u002Fchunks\u002Fpages\u002Fhead-7100d3b2a548f0e4.js"],
   "/hooks": ["static\u002Fchunks\u002Fpages\u002Fhooks-538d621a0e670391.js"],
-  "/image": ["static\u002Fchunks\u002Fpages\u002Fimage-53463827ccaef972.js"],
+  "/image": ["static\u002Fchunks\u002Fpages\u002Fimage-f97943edf7ae3dd3.js"],
   "/link": ["static\u002Fchunks\u002Fpages\u002Flink-f0a2c3bb0706d8b2.js"],
   "/routerDirect": [
     "static\u002Fchunks\u002Fpages\u002FrouterDirect-76232dd6bc335a24.js"
Diff for image-HASH.js
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/image",
         function() {
-          return __webpack_require__(5924);
+          return __webpack_require__(3155);
         }
       ]);
       if (false) {
@@ -1087,7 +1087,7 @@
       /***/
     },
 
-    /***/ 5924: /***/ function(
+    /***/ 3155: /***/ function(
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
Diff for main-HASH.js
@@ -474,8 +474,8 @@
       var _routeAnnouncer = __webpack_require__(8982);
       var _router1 = __webpack_require__(387);
       var _isError = __webpack_require__(676);
-      var _vitals = __webpack_require__(7813);
-      var _refresh = __webpack_require__(7739);
+      var _vitals = __webpack_require__(5834);
+      var _refresh = __webpack_require__(9831);
       function asyncGeneratorStep(
         gen,
         resolve,
@@ -628,7 +628,7 @@
         document.getElementById("__NEXT_DATA__").textContent
       );
       window.__NEXT_DATA__ = data;
-      var version = "12.0.10";
+      var version = "12.0.11-canary.3";
       exports.version = version;
       var looseToArray = function(input) {
         return [].slice.call(input);
@@ -980,16 +980,15 @@
                         props: hydrateProps,
                         err: initialErr
                       };
-                      if (false) {
+                      if (!opts.beforeRender) {
+                        _ctx.next = 42;
+                        break;
                       }
+                      _ctx.next = 42;
+                      return opts.beforeRender();
+                    case 42:
                       render(renderCtx);
-                      return _ctx.abrupt("return", emitter);
-                    case 44:
-                      return _ctx.abrupt("return", {
-                        emitter: emitter,
-                        renderCtx: renderCtx
-                      });
-                    case 45:
+                    case 43:
                     case "end":
                       return _ctx.stop();
                   }
@@ -1464,6 +1463,7 @@
         // don't cause any hydration delay:
         _react.default.useEffect(function() {
           (0, _performanceRelayer).default(onPerfEntry);
+          (0, _vitals).flushBufferedVitalsMetrics();
         }, []);
         return children;
       }
@@ -2768,28 +2768,6 @@
       /***/
     },
 
-    /***/ 7739: /***/ function(
-      __unused_webpack_module,
-      exports,
-      __webpack_require__
-    ) {
-      "use strict";
-
-      Object.defineProperty(exports, "__esModule", {
-        value: true
-      });
-      exports.useRefreshRoot = useRefreshRoot;
-      exports.RefreshContext = void 0;
-      var _react = __webpack_require__(7294);
-      var RefreshContext = (0, _react).createContext(function(_) {});
-      exports.RefreshContext = RefreshContext;
-      function useRefreshRoot() {
-        return (0, _react).useContext(RefreshContext);
-      } //# sourceMappingURL=refresh.js.map
-
-      /***/
-    },
-
     /***/ 699: /***/ function(
       __unused_webpack_module,
       exports,
@@ -3146,7 +3124,7 @@
       /***/
     },
 
-    /***/ 7813: /***/ function(
+    /***/ 9831: /***/ function(
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -3156,13 +3134,45 @@
       Object.defineProperty(exports, "__esModule", {
         value: true
       });
+      exports.useRefreshRoot = useRefreshRoot;
+      exports.RefreshContext = void 0;
+      var _react = __webpack_require__(7294);
+      var RefreshContext = (0, _react).createContext(function(_) {});
+      exports.RefreshContext = RefreshContext;
+      function useRefreshRoot() {
+        return (0, _react).useContext(RefreshContext);
+      } //# sourceMappingURL=refresh.js.map
+
+      /***/
+    },
+
+    /***/ 5834: /***/ function(
+      __unused_webpack_module,
+      exports,
+      __webpack_require__
+    ) {
+      "use strict";
+
+      Object.defineProperty(exports, "__esModule", {
+        value: true
+      });
+      exports.getBufferedVitalsMetrics = getBufferedVitalsMetrics;
+      exports.flushBufferedVitalsMetrics = flushBufferedVitalsMetrics;
       exports.trackWebVitalMetric = trackWebVitalMetric;
       exports.useWebVitalsReport = useWebVitalsReport;
       exports.webVitalsCallbacks = void 0;
       var _react = __webpack_require__(7294);
       var webVitalsCallbacks = new Set();
       exports.webVitalsCallbacks = webVitalsCallbacks;
+      var flushed = false;
       var metrics = [];
+      function getBufferedVitalsMetrics() {
+        return metrics;
+      }
+      function flushBufferedVitalsMetrics() {
+        flushed = true;
+        metrics.length = 0;
+      }
       function trackWebVitalMetric(metric) {
         metrics.push(metric);
         webVitalsCallbacks.forEach(function(callback) {
@@ -3171,6 +3181,8 @@
       }
       function useWebVitalsReport(callback) {
         var metricIndexRef = (0, _react).useRef(0);
+        if (false) {
+        }
         (0, _react).useEffect(
           function() {
             // Flush calculated metrics
@@ -5052,29 +5064,65 @@
                                   delBasePath(pathname)
                                 )
                               : pathname;
-                            if (shouldResolveHref && pathname !== "/_error") {
-                              options._shouldResolveHref = true;
-                              if (false) {
-                              } else {
-                                parsed.pathname = resolveDynamicRoute(
-                                  pathname,
-                                  pages
-                                );
-                                if (parsed.pathname !== pathname) {
-                                  pathname = parsed.pathname;
-                                  parsed.pathname = addBasePath(pathname);
-                                  url = (0, _utils).formatWithValidation(
-                                    parsed
-                                  );
-                                }
-                              }
+                            if (
+                              !(shouldResolveHref && pathname !== "/_error")
+                            ) {
+                              _ctx.next = 69;
+                              break;
+                            }
+                            options._shouldResolveHref = true;
+                            if (true) {
+                              _ctx.next = 68;
+                              break;
+                            }
+                            rewritesResult = (0, _resolveRewrites).default(
+                              addBasePath(addLocale(cleanedAs, _this.locale)),
+                              pages,
+                              rewrites,
+                              query,
+                              function(p) {
+                                return resolveDynamicRoute(p, pages);
+                              },
+                              _this.locales
+                            );
+                            if (!rewritesResult.externalDest) {
+                              _ctx.next = 64;
+                              break;
+                            }
+                            location.href = as;
+                            return _ctx.abrupt("return", true);
+                          case 64:
+                            resolvedAs = rewritesResult.asPath;
+                            if (
+                              rewritesResult.matchedPage &&
+                              rewritesResult.resolvedHref
+                            ) {
+                              // if this directly matches a page we need to update the href to
+                              // allow the correct page chunk to be loaded
+                              pathname = rewritesResult.resolvedHref;
+                              parsed.pathname = addBasePath(pathname);
+                              url = (0, _utils).formatWithValidation(parsed);
+                            }
+                            _ctx.next = 69;
+                            break;
+                          case 68: {
+                            parsed.pathname = resolveDynamicRoute(
+                              pathname,
+                              pages
+                            );
+                            if (parsed.pathname !== pathname) {
+                              pathname = parsed.pathname;
+                              parsed.pathname = addBasePath(pathname);
+                              url = (0, _utils).formatWithValidation(parsed);
                             }
+                          }
+                          case 69:
                             if (isLocalURL(as)) {
-                              _ctx.next = 63;
+                              _ctx.next = 74;
                               break;
                             }
                             if (true) {
-                              _ctx.next = 61;
+                              _ctx.next = 72;
                               break;
                             }
                             throw new Error(
@@ -5086,10 +5134,10 @@
                                 ) +
                                 "\nSee more info: https://nextjs.org/docs/messages/invalid-relative-url-external-as"
                             );
-                          case 61:
+                          case 72:
                             window.location.href = as;
                             return _ctx.abrupt("return", false);
-                          case 63:
+                          case 74:
                             resolvedAs = delLocale(
                               delBasePath(resolvedAs),
                               _this.locale
@@ -5105,10 +5153,10 @@
                                 )
                               )
                             ) {
-                              _ctx.next = 84;
+                              _ctx.next = 95;
                               break;
                             }
-                            _ctx.next = 67;
+                            _ctx.next = 78;
                             return _this._preflightRequest({
                               as: as,
                               cache: "production" === "production",
@@ -5116,10 +5164,10 @@
                               pathname: pathname,
                               query: query
                             });
-                          case 67:
+                          case 78:
                             effect = _ctx.sent;
                             if (!(effect.type === "rewrite")) {
-                              _ctx.next = 72;
+                              _ctx.next = 83;
                               break;
                             }
                             {
@@ -5133,11 +5181,11 @@
                               parsed.pathname = effect.resolvedHref;
                               url = (0, _utils).formatWithValidation(parsed);
                             }
-                            _ctx.next = 84;
+                            _ctx.next = 95;
                             break;
-                          case 72:
+                          case 83:
                             if (!(effect.type === "redirect" && effect.newAs)) {
-                              _ctx.next = 76;
+                              _ctx.next = 87;
                               break;
                             }
                             return _ctx.abrupt(
@@ -5149,13 +5197,13 @@
                                 options
                               )
                             );
-                          case 76:
+                          case 87:
                             if (
                               !(
                                 effect.type === "redirect" && effect.destination
                               )
                             ) {
-                              _ctx.next = 81;
+                              _ctx.next = 92;
                               break;
                             }
                             window.location.href = effect.destination;
@@ -5163,14 +5211,14 @@
                               "return",
                               new Promise(function() {})
                             );
-                          case 81:
+                          case 92:
                             if (
                               !(
                                 effect.type === "refresh" &&
                                 as !== window.location.pathname
                               )
                             ) {
-                              _ctx.next = 84;
+                              _ctx.next = 95;
                               break;
                             }
                             window.location.href = as;
@@ -5178,13 +5226,13 @@
                               "return",
                               new Promise(function() {})
                             );
-                          case 84:
+                          case 95:
                             route = (0,
                             _normalizeTrailingSlash).removePathTrailingSlash(
                               pathname
                             );
                             if (!(0, _isDynamic).isDynamicRoute(route)) {
-                              _ctx.next = 100;
+                              _ctx.next = 111;
                               break;
                             }
                             parsedAs1 = (0, _parseRelativeUrl).parseRelativeUrl(
@@ -5205,7 +5253,7 @@
                                 (shouldInterpolate && !interpolatedAs.result)
                               )
                             ) {
-                              _ctx.next = 99;
+                              _ctx.next = 110;
                               break;
                             }
                             missingParams = Object.keys(
@@ -5214,7 +5262,7 @@
                               return !query[param];
                             });
                             if (!(missingParams.length > 0)) {
-                              _ctx.next = 97;
+                              _ctx.next = 108;
                               break;
                             }
                             if (false) {
@@ -5242,10 +5290,10 @@
                                     : "incompatible-href-as"
                                 )
                             );
-                          case 97:
-                            _ctx.next = 100;
+                          case 108:
+                            _ctx.next = 111;
                             break;
-                          case 99:
+                          case 110:
                             if (shouldInterpolate) {
                               as = (0, _utils).formatWithValidation(
                                 Object.assign({}, parsedAs1, {
@@ -5260,14 +5308,14 @@
                               // Merge params into `query`, overwriting any specified in search
                               Object.assign(query, routeMatch);
                             }
-                          case 100:
+                          case 111:
                             Router.events.emit(
                               "routeChangeStart",
                               as,
                               routeProps
                             );
-                            _ctx.prev = 101;
-                            _ctx.next = 105;
+                            _ctx.prev = 112;
+                            _ctx.next = 116;
                             return _this.getRouteInfo(
                               route,
                               pathname,
@@ -5276,20 +5324,20 @@
                               resolvedAs,
                               routeProps
                             );
-                          case 105:
+                          case 116:
                             routeInfo = _ctx.sent;
                             (error = routeInfo.error),
                               (props = routeInfo.props),
                               (__N_SSG = routeInfo.__N_SSG),
                               (__N_SSP = routeInfo.__N_SSP);
                             if (!((__N_SSG || __N_SSP) && props)) {
-                              _ctx.next = 132;
+                              _ctx.next = 143;
                               break;
                             }
                             if (
                               !(props.pageProps && props.pageProps.__N_REDIRECT)
                             ) {
-                              _ctx.next = 117;
+                              _ctx.next = 128;
                               break;
                             }
                             destination = props.pageProps.__N_REDIRECT;
@@ -5299,7 +5347,7 @@
                                 props.pageProps.__N_REDIRECT_BASE_PATH !== false
                               )
                             ) {
-                              _ctx.next = 115;
+                              _ctx.next = 126;
                               break;
                             }
                             parsedHref = (0,
@@ -5319,31 +5367,31 @@
                               "return",
                               _this.change(method, newUrl, newAs, options)
                             );
-                          case 115:
+                          case 126:
                             window.location.href = destination;
                             return _ctx.abrupt(
                               "return",
                               new Promise(function() {})
                             );
-                          case 117:
+                          case 128:
                             _this.isPreview = !!props.__N_PREVIEW;
                             if (!(props.notFound === SSG_DATA_NOT_FOUND)) {
-                              _ctx.next = 132;
+                              _ctx.next = 143;
                               break;
                             }
-                            _ctx.prev = 120;
-                            _ctx.next = 123;
+                            _ctx.prev = 131;
+                            _ctx.next = 134;
                             return _this.fetchComponent("/404");
-                          case 123:
+                          case 134:
                             notFoundRoute = "/404";
-                            _ctx.next = 129;
+                            _ctx.next = 140;
                             break;
-                          case 126:
-                            _ctx.prev = 126;
-                            _ctx.t3 = _ctx["catch"](120);
+                          case 137:
+                            _ctx.prev = 137;
+                            _ctx.t3 = _ctx["catch"](131);
                             notFoundRoute = "/_error";
-                          case 129:
-                            _ctx.next = 131;
+                          case 140:
+                            _ctx.next = 142;
                             return _this.getRouteInfo(
                               notFoundRoute,
                               notFoundRoute,
@@ -5354,9 +5402,9 @@
                                 shallow: false
                               }
                             );
-                          case 131:
+                          case 142:
                             routeInfo = _ctx.sent;
-                          case 132:
+                          case 143:
                             Router.events.emit(
                               "beforeHistoryChange",
                               as,
@@ -5394,7 +5442,7 @@
                                   y: 0
                                 }
                               : null;
-                            _ctx.next = 141;
+                            _ctx.next = 152;
                             return _this
                               .set(
                                 route,
@@ -5410,9 +5458,9 @@
                                 if (e.cancelled) error = error || e;
                                 else throw e;
                               });
-                          case 141:
+                          case 152:
                             if (!error) {
-                              _ctx.next = 144;
+                              _ctx.next = 155;
                               break;
                             }
                             Router.events.emit(
@@ -5422,7 +5470,7 @@
                               routeProps
                             );
                             throw error;
-                          case 144:
+                          case 155:
                             if (false) {
                             }
                             Router.events.emit(
@@ -5431,22 +5479,22 @@
                               routeProps
                             );
                             return _ctx.abrupt("return", true);
-                          case 149:
-                            _ctx.prev = 149;
-                            _ctx.t4 = _ctx["catch"](101);
+                          case 160:
+                            _ctx.prev = 160;
+                            _ctx.t4 = _ctx["catch"](112);
                             if (
                               !(
                                 (0, _isError).default(_ctx.t4) &&
                                 _ctx.t4.cancelled
                               )
                             ) {
-                              _ctx.next = 153;
+                              _ctx.next = 164;
                               break;
                             }
                             return _ctx.abrupt("return", false);
-                          case 153:
+                          case 164:
                             throw _ctx.t4;
-                          case 154:
+                          case 165:
                           case "end":
                             return _ctx.stop();
                         }
@@ -5455,8 +5503,8 @@
                     null,
                     [
                       [38, 50],
-                      [101, 149],
-                      [120, 126]
+                      [112, 160],
+                      [131, 137]
                     ]
                   );
                 })
@@ -5932,7 +5980,7 @@
                           pages = _ctx.sent;
                           resolvedAs = asPath;
                           if (true) {
-                            _ctx.next = 20;
+                            _ctx.next = 22;
                             break;
                           }
                           _ctx.next = 12;
@@ -5951,6 +5999,12 @@
                             },
                             _this.locales
                           );
+                          if (!rewritesResult.externalDest) {
+                            _ctx.next = 18;
+                            break;
+                          }
+                          return _ctx.abrupt("return");
+                        case 18:
                           resolvedAs = delLocale(
                             delBasePath(rewritesResult.asPath),
                             _this.locale
@@ -5965,9 +6019,9 @@
                             parsed.pathname = pathname;
                             url = (0, _utils).formatWithValidation(parsed);
                           }
-                          _ctx.next = 21;
+                          _ctx.next = 23;
                           break;
-                        case 20: {
+                        case 22: {
                           parsed.pathname = resolveDynamicRoute(
                             parsed.pathname,
                             pages
@@ -5978,14 +6032,14 @@
                             url = (0, _utils).formatWithValidation(parsed);
                           }
                         }
-                        case 21:
+                        case 23:
                           if (true) {
-                            _ctx.next = 23;
+                            _ctx.next = 25;
                             break;
                           }
                           return _ctx.abrupt("return");
-                        case 23:
-                          _ctx.next = 25;
+                        case 25:
+                          _ctx.next = 27;
                           return _this._preflightRequest({
                             as: addBasePath(asPath),
                             cache: true,
@@ -5993,7 +6047,7 @@
                             pathname: pathname,
                             query: query
                           });
-                        case 25:
+                        case 27:
                           effects = _ctx.sent;
                           if (effects.type === "rewrite") {
                             parsed.pathname = effects.resolvedHref;
@@ -6010,7 +6064,7 @@
                           _normalizeTrailingSlash).removePathTrailingSlash(
                             pathname
                           );
-                          _ctx.next = 30;
+                          _ctx.next = 32;
                           return Promise.all([
                             _this.pageLoader
                               ._isSsg(route)
@@ -6037,7 +6091,7 @@
                               options.priority ? "loadPage" : "prefetch"
                             ](route)
                           ]);
-                        case 30:
+                        case 32:
                         case "end":
                           return _ctx.stop();
                       }
Diff for index.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-c6fc133fe313f8ea.js"
+      src="/_next/static/chunks/main-4a361f38a90cd320.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-c6fc133fe313f8ea.js"
+      src="/_next/static/chunks/main-4a361f38a90cd320.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-c6fc133fe313f8ea.js"
+      src="/_next/static/chunks/main-4a361f38a90cd320.js"
       defer=""
     ></script>
     <script

Please sign in to comment.