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 optimizeFonts (Automatic font optimization) superseded by next/font #69137

Conversation

timneutkens
Copy link
Member

@timneutkens timneutkens commented Aug 21, 2024

What?

The optimizeFonts optimization has been replaced by next/font for almost 2 years and was already no longer documented. This PR cleans up the code related to it. It's recommended to use next/font as it's better in every way, ensuring you get preloading of the font but also a local fallback and better fallbacks.

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. tests type: next labels Aug 21, 2024
Copy link
Member Author

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

Join @timneutkens and the rest of your teammates on Graphite Graphite

@timneutkens timneutkens marked this pull request as ready for review August 21, 2024 09:32
@ijjk
Copy link
Member

ijjk commented Aug 21, 2024

Stats from current PR

Default Build
General
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
buildDuration 17.2s 15.6s N/A
buildDurationCached 8.7s 7.2s N/A
nodeModulesSize 356 MB 356 MB N/A
nextStartRea..uration (ms) 412ms 415ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
1921-HASH.js gzip 37.9 kB 37.9 kB N/A
1995.HASH.js gzip 169 B 169 B
66c22fe9-HASH.js gzip 51.9 kB 51.9 kB N/A
9018-HASH.js gzip 5.19 kB 5.25 kB N/A
framework-HASH.js gzip 56.7 kB 56.7 kB
main-app-HASH.js gzip 226 B 226 B
main-HASH.js gzip 32.5 kB 32.5 kB N/A
webpack-HASH.js gzip 1.71 kB 1.71 kB N/A
Overall change 57.1 kB 57.1 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
_app-HASH.js gzip 192 B 193 B N/A
_error-HASH.js gzip 193 B 192 B N/A
amp-HASH.js gzip 512 B 510 B N/A
css-HASH.js gzip 342 B 342 B
dynamic-HASH.js gzip 1.84 kB 1.84 kB N/A
edge-ssr-HASH.js gzip 265 B 264 B N/A
head-HASH.js gzip 363 B 364 B N/A
hooks-HASH.js gzip 391 B 392 B N/A
image-HASH.js gzip 4.39 kB 4.4 kB N/A
index-HASH.js gzip 269 B 268 B N/A
link-HASH.js gzip 2.82 kB 2.81 kB N/A
routerDirect..HASH.js gzip 328 B 326 B N/A
script-HASH.js gzip 396 B 396 B
withRouter-HASH.js gzip 325 B 324 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 844 B 844 B
Client Build Manifests
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
_buildManifest.js gzip 749 B 748 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
index.html gzip 521 B 522 B N/A
link.html gzip 534 B 537 B N/A
withRouter.html gzip 517 B 520 B N/A
Overall change 0 B 0 B
Edge SSR bundle Size
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
edge-ssr.js gzip 128 kB 127 kB N/A
page.js gzip 173 kB 173 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
middleware-b..fest.js gzip 667 B 670 B N/A
middleware-r..fest.js gzip 156 B 155 B N/A
middleware.js gzip 29.7 kB 29.7 kB N/A
edge-runtime..pack.js gzip 844 B 844 B
Overall change 844 B 844 B
Next Runtimes
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
928-experime...dev.js gzip 322 B 322 B
928.runtime.dev.js gzip 314 B 314 B
app-page-exp...dev.js gzip 309 kB 309 kB
app-page-exp..prod.js gzip 122 kB 122 kB
app-page-tur..prod.js gzip 135 kB 135 kB
app-page-tur..prod.js gzip 130 kB 130 kB
app-page.run...dev.js gzip 298 kB 298 kB
app-page.run..prod.js gzip 118 kB 118 kB
app-route-ex...dev.js gzip 30.7 kB 30.7 kB
app-route-ex..prod.js gzip 20.7 kB 20.7 kB
app-route-tu..prod.js gzip 20.7 kB 20.7 kB
app-route-tu..prod.js gzip 20.5 kB 20.5 kB
app-route.ru...dev.js gzip 32.4 kB 32.4 kB
app-route.ru..prod.js gzip 20.5 kB 20.5 kB
pages-api-tu..prod.js gzip 9.62 kB 9.62 kB
pages-api.ru...dev.js gzip 11.5 kB 11.5 kB
pages-api.ru..prod.js gzip 9.61 kB 9.61 kB
pages-turbo...prod.js gzip 21.6 kB 20.8 kB N/A
pages.runtim...dev.js gzip 27.5 kB 26.4 kB N/A
pages.runtim..prod.js gzip 21.6 kB 20.8 kB N/A
server.runti..prod.js gzip 57 kB 56.9 kB N/A
Overall change 1.29 MB 1.29 MB
build cache
vercel/next.js canary vercel/next.js 08-21-turbopack_build_ensure_all_font_optimization_tests_run Change
0.pack gzip 1.49 MB 1.49 MB N/A
index.pack gzip 127 kB 127 kB N/A
Overall change 0 B 0 B
Diff details
Diff for page.js

Diff too large to display

Diff for middleware.js

Diff too large to display

Diff for edge-ssr.js

Diff too large to display

Diff for image-HASH.js
@@ -1,7 +1,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [8358],
   {
-    /***/ 6835: /***/ (
+    /***/ 9606: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
@@ -9,7 +9,7 @@
       (window.__NEXT_P = window.__NEXT_P || []).push([
         "/image",
         function () {
-          return __webpack_require__(1274);
+          return __webpack_require__(9670);
         },
       ]);
       if (false) {
@@ -18,7 +18,7 @@
       /***/
     },
 
-    /***/ 9784: /***/ (module, exports, __webpack_require__) => {
+    /***/ 6307: /***/ (module, exports, __webpack_require__) => {
       "use strict";
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
@@ -40,17 +40,17 @@
         __webpack_require__(7864)
       );
       const _head = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(4888)
+        __webpack_require__(4984)
       );
-      const _getimgprops = __webpack_require__(7204);
-      const _imageconfig = __webpack_require__(5319);
-      const _imageconfigcontextsharedruntime = __webpack_require__(3170);
-      const _warnonce = __webpack_require__(7920);
-      const _routercontextsharedruntime = __webpack_require__(7209);
+      const _getimgprops = __webpack_require__(4855);
+      const _imageconfig = __webpack_require__(4609);
+      const _imageconfigcontextsharedruntime = __webpack_require__(3316);
+      const _warnonce = __webpack_require__(2651);
+      const _routercontextsharedruntime = __webpack_require__(4057);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(7443)
+        __webpack_require__(8495)
       );
-      const _usemergedref = __webpack_require__(2531);
+      const _usemergedref = __webpack_require__(7553);
       // This is replaced by webpack define plugin
       const configEnv = {
         deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
@@ -371,7 +371,7 @@
       /***/
     },
 
-    /***/ 2531: /***/ (module, exports, __webpack_require__) => {
+    /***/ 7553: /***/ (module, exports, __webpack_require__) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -440,7 +440,7 @@
       /***/
     },
 
-    /***/ 7204: /***/ (
+    /***/ 4855: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -456,9 +456,9 @@
           return getImgProps;
         },
       });
-      const _warnonce = __webpack_require__(7920);
-      const _imageblursvg = __webpack_require__(2200);
-      const _imageconfig = __webpack_require__(5319);
+      const _warnonce = __webpack_require__(2651);
+      const _imageblursvg = __webpack_require__(5067);
+      const _imageconfig = __webpack_require__(4609);
       const VALID_LOADING_VALUES =
         /* unused pure expression or super */ null && [
           "lazy",
@@ -830,7 +830,7 @@
       /***/
     },
 
-    /***/ 2200: /***/ (__unused_webpack_module, exports) => {
+    /***/ 5067: /***/ (__unused_webpack_module, exports) => {
       "use strict";
       /**
        * A shared function, used on both client and server, to generate a SVG blur placeholder.
@@ -885,7 +885,7 @@
       /***/
     },
 
-    /***/ 1356: /***/ (
+    /***/ 3505: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -912,10 +912,10 @@
         },
       });
       const _interop_require_default = __webpack_require__(4345);
-      const _getimgprops = __webpack_require__(7204);
-      const _imagecomponent = __webpack_require__(9784);
+      const _getimgprops = __webpack_require__(4855);
+      const _imagecomponent = __webpack_require__(6307);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(7443)
+        __webpack_require__(8495)
       );
       function getImageProps(imgProps) {
         const { props } = (0, _getimgprops.getImgProps)(imgProps, {
@@ -947,7 +947,7 @@
       /***/
     },
 
-    /***/ 7443: /***/ (__unused_webpack_module, exports) => {
+    /***/ 8495: /***/ (__unused_webpack_module, exports) => {
       "use strict";
 
       Object.defineProperty(exports, "__esModule", {
@@ -982,7 +982,7 @@
       /***/
     },
 
-    /***/ 1274: /***/ (
+    /***/ 9670: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -999,8 +999,8 @@
 
       // EXTERNAL MODULE: ./node_modules/.pnpm/react@19.0.0-rc-1eaccd82-20240816/node_modules/react/jsx-runtime.js
       var jsx_runtime = __webpack_require__(1822);
-      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+main-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-1eaccd82-20240816_re_5yc7ktq4kyrrvzaq2fultvg3y4/node_modules/next/image.js
-      var next_image = __webpack_require__(7091);
+      // EXTERNAL MODULE: ./node_modules/.pnpm/next@file+..+diff-repo+packages+next+next-packed.tgz_react-dom@19.0.0-rc-1eaccd82-20240816_re_kxzj53dvrxjpf46fi64kfjrpy4/node_modules/next/image.js
+      var next_image = __webpack_require__(142);
       var image_default = /*#__PURE__*/ __webpack_require__.n(next_image); // CONCATENATED MODULE: ./pages/nextjs.png
       /* harmony default export */ const nextjs = {
         src: "/_next/static/media/nextjs.cae0b805.png",
@@ -1030,12 +1030,12 @@
       /***/
     },
 
-    /***/ 7091: /***/ (
+    /***/ 142: /***/ (
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
-      module.exports = __webpack_require__(1356);
+      module.exports = __webpack_require__(3505);
 
       /***/
     },
@@ -1045,7 +1045,7 @@
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
     /******/ __webpack_require__.O(0, [2888, 9774, 179], () =>
-      __webpack_exec__(6835)
+      __webpack_exec__(9606)
     );
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Diff for 9018-HASH.js
@@ -1,8 +1,8 @@
 "use strict";
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
-  [9018],
+  [9149],
   {
-    /***/ 9018: /***/ (module, exports, __webpack_require__) => {
+    /***/ 9149: /***/ (module, exports, __webpack_require__) => {
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
         value: true,
@@ -13,27 +13,27 @@
           return Image;
         },
       });
-      const _interop_require_default = __webpack_require__(9384);
-      const _interop_require_wildcard = __webpack_require__(9913);
-      const _jsxruntime = __webpack_require__(9113);
+      const _interop_require_default = __webpack_require__(8232);
+      const _interop_require_wildcard = __webpack_require__(5339);
+      const _jsxruntime = __webpack_require__(5335);
       const _react = /*#__PURE__*/ _interop_require_wildcard._(
-        __webpack_require__(6193)
+        __webpack_require__(9960)
       );
       const _reactdom = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(2527)
+        __webpack_require__(7851)
       );
       const _head = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(5723)
+        __webpack_require__(5358)
       );
-      const _getimgprops = __webpack_require__(7428);
-      const _imageconfig = __webpack_require__(4011);
-      const _imageconfigcontextsharedruntime = __webpack_require__(7352);
-      const _warnonce = __webpack_require__(1970);
-      const _routercontextsharedruntime = __webpack_require__(1015);
+      const _getimgprops = __webpack_require__(8934);
+      const _imageconfig = __webpack_require__(4021);
+      const _imageconfigcontextsharedruntime = __webpack_require__(614);
+      const _warnonce = __webpack_require__(6748);
+      const _routercontextsharedruntime = __webpack_require__(1013);
       const _imageloader = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(22)
+        __webpack_require__(3003)
       );
-      const _usemergedref = __webpack_require__(3501);
+      const _usemergedref = __webpack_require__(9648);
       // This is replaced by webpack define plugin
       const configEnv = {
         deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
@@ -355,7 +355,7 @@
       /***/
     },
 
-    /***/ 3501: /***/ (module, exports, __webpack_require__) => {
+    /***/ 9648: /***/ (module, exports, __webpack_require__) => {
       Object.defineProperty(exports, "__esModule", {
         value: true,
       });
@@ -375,7 +375,7 @@
           return useMergedRef;
         },
       });
-      const _react = __webpack_require__(6193);
+      const _react = __webpack_require__(9960);
       function useMergedRef(refA, refB) {
         return (0, _react.useMemo)(() => mergeRefs(refA, refB), [refA, refB]);
       }
@@ -422,11 +422,7 @@
       /***/
     },
 
-    /***/ 4783: /***/ (
-      __unused_webpack_module,
-      exports,
-      __webpack_require__
-    ) => {
+    /***/ 31: /***/ (__unused_webpack_module, exports, __webpack_require__) => {
       Object.defineProperty(exports, "__esModule", {
         value: true,
       });
@@ -436,9 +432,9 @@
           return AmpStateContext;
         },
       });
-      const _interop_require_default = __webpack_require__(9384);
+      const _interop_require_default = __webpack_require__(8232);
       const _react = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(6193)
+        __webpack_require__(9960)
       );
       const AmpStateContext = _react.default.createContext({});
       if (false) {
@@ -447,7 +443,7 @@
       /***/
     },
 
-    /***/ 4122: /***/ (__unused_webpack_module, exports) => {
+    /***/ 3208: /***/ (__unused_webpack_module, exports) => {
       Object.defineProperty(exports, "__esModule", {
         value: true,
       });
@@ -469,7 +465,7 @@
       /***/
     },
 
-    /***/ 7428: /***/ (
+    /***/ 8934: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -483,9 +479,9 @@
           return getImgProps;
         },
       });
-      const _warnonce = __webpack_require__(1970);
-      const _imageblursvg = __webpack_require__(7992);
-      const _imageconfig = __webpack_require__(4011);
+      const _warnonce = __webpack_require__(6748);
+      const _imageblursvg = __webpack_require__(9736);
+      const _imageconfig = __webpack_require__(4021);
       const VALID_LOADING_VALUES =
         /* unused pure expression or super */ null && [
           "lazy",
@@ -857,7 +853,8 @@
       /***/
     },
 
-    /***/ 5723: /***/ (module, exports, __webpack_require__) => {
+    /***/ 5358: /***/ (module, exports, __webpack_require__) => {
+      /* provided dependency */ var process = __webpack_require__(3741);
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
         value: true,
@@ -878,19 +875,19 @@
           return defaultHead;
         },
       });
-      const _interop_require_default = __webpack_require__(9384);
-      const _interop_require_wildcard = __webpack_require__(9913);
-      const _jsxruntime = __webpack_require__(9113);
+      const _interop_require_default = __webpack_require__(8232);
+      const _interop_require_wildcard = __webpack_require__(5339);
+      const _jsxruntime = __webpack_require__(5335);
       const _react = /*#__PURE__*/ _interop_require_wildcard._(
-        __webpack_require__(6193)
+        __webpack_require__(9960)
       );
       const _sideeffect = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(2907)
+        __webpack_require__(114)
       );
-      const _ampcontextsharedruntime = __webpack_require__(4783);
-      const _headmanagercontextsharedruntime = __webpack_require__(1854);
-      const _ampmode = __webpack_require__(4122);
-      const _warnonce = __webpack_require__(1970);
+      const _ampcontextsharedruntime = __webpack_require__(31);
+      const _headmanagercontextsharedruntime = __webpack_require__(866);
+      const _ampmode = __webpack_require__(3208);
+      const _warnonce = __webpack_require__(6748);
       function defaultHead(inAmpMode) {
         if (inAmpMode === void 0) inAmpMode = false;
         const head = [
@@ -1014,7 +1011,7 @@
           .reverse()
           .map((c, i) => {
             const key = c.key || i;
-            if (true && !inAmpMode) {
+            if (true && process.env.__NEXT_OPTIMIZE_FONTS && !inAmpMode) {
               if (
                 c.type === "link" &&
                 c.props["href"] && // TODO(prateekbh@): Replace this with const from `constants` when the tree shaking works.
@@ -1074,7 +1071,7 @@
       /***/
     },
 
-    /***/ 7992: /***/ (__unused_webpack_module, exports) => {
+    /***/ 9736: /***/ (__unused_webpack_module, exports) => {
       /**
        * A shared function, used on both client and server, to generate a SVG blur placeholder.
        */
@@ -1128,7 +1125,7 @@
       /***/
     },
 
-    /***/ 7352: /***/ (
+    /***/ 614: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -1142,11 +1139,11 @@
           return ImageConfigContext;
         },
       });
-      const _interop_require_default = __webpack_require__(9384);
+      const _interop_require_default = __webpack_require__(8232);
       const _react = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(6193)
+        __webpack_require__(9960)
       );
-      const _imageconfig = __webpack_require__(4011);
+      const _imageconfig = __webpack_require__(4021);
       const ImageConfigContext = _react.default.createContext(
         _imageconfig.imageConfigDefault
       );
@@ -1156,7 +1153,7 @@
       /***/
     },
 
-    /***/ 4011: /***/ (__unused_webpack_module, exports) => {
+    /***/ 4021: /***/ (__unused_webpack_module, exports) => {
       Object.defineProperty(exports, "__esModule", {
         value: true,
       });
@@ -1203,7 +1200,7 @@
       /***/
     },
 
-    /***/ 22: /***/ (__unused_webpack_module, exports) => {
+    /***/ 3003: /***/ (__unused_webpack_module, exports) => {
       Object.defineProperty(exports, "__esModule", {
         value: true,
       });
@@ -1236,7 +1233,7 @@
       /***/
     },
 
-    /***/ 1015: /***/ (
+    /***/ 1013: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -1250,9 +1247,9 @@
           return RouterContext;
         },
       });
-      const _interop_require_default = __webpack_require__(9384);
+      const _interop_require_default = __webpack_require__(8232);
       const _react = /*#__PURE__*/ _interop_require_default._(
-        __webpack_require__(6193)
+        __webpack_require__(9960)
       );
       const RouterContext = _react.default.createContext(null);
       if (false) {
@@ -1261,7 +1258,7 @@
       /***/
     },
 
-    /***/ 2907: /***/ (
+    /***/ 114: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -1275,7 +1272,7 @@
           return SideEffect;
         },
       });
-      const _react = __webpack_require__(6193);
+      const _react = __webpack_require__(9960);
       const isServer = typeof window === "undefined";
       const useClientOnlyLayoutEffect = isServer
         ? () => {}
Diff for main-HASH.js

Diff too large to display

Diff for pages-turbo...time.prod.js

Diff too large to display

Diff for pages.runtime.dev.js

Diff too large to display

Diff for pages.runtime.prod.js

Diff too large to display

Diff for server.runtime.prod.js

Diff too large to display

Commit: 356daa1

@ijjk
Copy link
Member

ijjk commented Aug 21, 2024

Tests Passed

@ijjk ijjk added the Font (next/font) Related to Next.js Font Optimization. label Aug 21, 2024
@timneutkens timneutkens marked this pull request as draft August 21, 2024 14:04
@timneutkens timneutkens changed the title Turbopack build: Ensure all font optimization tests run Remove optimizeFonts (Automatic font optimization) superseded by next/font Aug 21, 2024
@timneutkens timneutkens marked this pull request as ready for review August 21, 2024 18:36
@timneutkens timneutkens merged commit 3ab6d17 into canary Aug 21, 2024
94 of 99 checks passed
@timneutkens timneutkens deleted the 08-21-turbopack_build_ensure_all_font_optimization_tests_run branch August 21, 2024 19:39
@github-actions github-actions bot added the locked label Sep 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. Font (next/font) Related to Next.js Font Optimization. locked tests type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants