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

feat(turbopack): Use mangled export names for fake exports #69124

Open
wants to merge 5 commits into
base: canary
Choose a base branch
from

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Aug 21, 2024

What?

Use _ as the name of the export if possible.

Why?

It will reduce the final bundle size.

How?

Closes PACK-3209

@kdy1 kdy1 self-assigned this Aug 21, 2024
@ijjk ijjk added the created-by: Turbopack team PRs by the Turbopack team. label Aug 21, 2024
@ijjk
Copy link
Member

ijjk commented Aug 21, 2024

Tests Passed

@ijjk
Copy link
Member

ijjk commented Aug 21, 2024

Stats from current PR

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary vercel/next.js kdy1/mangle Change
buildDuration 18.3s 18.3s N/A
buildDurationCached 8.5s 7.5s N/A
nodeModulesSize 356 MB 356 MB ⚠️ +372 kB
nextStartRea..uration (ms) 425ms 429ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js kdy1/mangle 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.25 kB 5.19 kB N/A
framework-HASH.js gzip 56.7 kB 56.7 kB
main-app-HASH.js gzip 225 B 224 B N/A
main-HASH.js gzip 32.5 kB 32.6 kB N/A
webpack-HASH.js gzip 1.71 kB 1.71 kB N/A
Overall change 56.9 kB 56.9 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js kdy1/mangle Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js kdy1/mangle 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 kdy1/mangle 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 kdy1/mangle Change
index.html gzip 523 B 523 B
link.html gzip 535 B 538 B N/A
withRouter.html gzip 519 B 520 B N/A
Overall change 523 B 523 B
Edge SSR bundle Size Overall increase ⚠️
vercel/next.js canary vercel/next.js kdy1/mangle Change
edge-ssr.js gzip 127 kB 128 kB ⚠️ +395 B
page.js gzip 173 kB 173 kB ⚠️ +191 B
Overall change 300 kB 301 kB ⚠️ +586 B
Middleware size
vercel/next.js canary vercel/next.js kdy1/mangle Change
middleware-b..fest.js gzip 668 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 Overall increase ⚠️
vercel/next.js canary vercel/next.js kdy1/mangle 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 N/A
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 N/A
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 20.8 kB 21.6 kB ⚠️ +828 B
pages.runtim...dev.js gzip 26.4 kB 27.5 kB ⚠️ +1.17 kB
pages.runtim..prod.js gzip 20.8 kB 21.6 kB ⚠️ +829 B
server.runti..prod.js gzip 56.8 kB 57 kB ⚠️ +166 B
Overall change 807 kB 810 kB ⚠️ +2.99 kB
build cache Overall increase ⚠️
vercel/next.js canary vercel/next.js kdy1/mangle Change
0.pack gzip 1.49 MB 1.49 MB ⚠️ +6.87 kB
index.pack gzip 127 kB 127 kB ⚠️ +115 B
Overall change 1.61 MB 1.62 MB ⚠️ +6.98 kB
Diff details
Diff for page.js

Diff too large to display

Diff for middleware.js

Diff too large to display

Diff for edge-ssr.js

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 1921-HASH.js

Diff too large to display

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,8 +853,7 @@
       /***/
     },
 
-    /***/ 5723: /***/ (module, exports, __webpack_require__) => {
-      /* provided dependency */ var process = __webpack_require__(455);
+    /***/ 5358: /***/ (module, exports, __webpack_require__) => {
       /* __next_internal_client_entry_do_not_use__  cjs */
       Object.defineProperty(exports, "__esModule", {
         value: true,
@@ -879,19 +874,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 = [
@@ -1015,7 +1010,7 @@
           .reverse()
           .map((c, i) => {
             const key = c.key || i;
-            if (true && process.env.__NEXT_OPTIMIZE_FONTS && !inAmpMode) {
+            if (true && !inAmpMode) {
               if (
                 c.type === "link" &&
                 c.props["href"] && // TODO(prateekbh@): Replace this with const from `constants` when the tree shaking works.
@@ -1075,7 +1070,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.
        */
@@ -1129,7 +1124,7 @@
       /***/
     },
 
-    /***/ 7352: /***/ (
+    /***/ 614: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -1143,11 +1138,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
       );
@@ -1157,7 +1152,7 @@
       /***/
     },
 
-    /***/ 4011: /***/ (__unused_webpack_module, exports) => {
+    /***/ 4021: /***/ (__unused_webpack_module, exports) => {
       Object.defineProperty(exports, "__esModule", {
         value: true,
       });
@@ -1204,7 +1199,7 @@
       /***/
     },
 
-    /***/ 22: /***/ (__unused_webpack_module, exports) => {
+    /***/ 3003: /***/ (__unused_webpack_module, exports) => {
       Object.defineProperty(exports, "__esModule", {
         value: true,
       });
@@ -1237,7 +1232,7 @@
       /***/
     },
 
-    /***/ 1015: /***/ (
+    /***/ 1013: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -1251,9 +1246,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) {
@@ -1262,7 +1257,7 @@
       /***/
     },
 
-    /***/ 2907: /***/ (
+    /***/ 114: /***/ (
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -1276,7 +1271,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: b7d12e7

@kdy1 kdy1 changed the title feat(turbopack): Use _ as export name for intermediate exports feat(turbopack): Use mangled export names for fake exports Aug 22, 2024
@kdy1 kdy1 marked this pull request as ready for review August 22, 2024 05:05
@kdy1 kdy1 requested a review from sokra August 22, 2024 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Turbopack team PRs by the Turbopack team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants