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

Bypass webpack compilation for precompiled @next/polyfills-nomodule #27596

Merged

Conversation

timneutkens
Copy link
Member

@timneutkens timneutkens commented Jul 29, 2021

Removes the extra webpack handling that was previously done, this ensures the file which is already minified and compiled does not get passed through minification again.

Largely based on #21418
Closes #21418

The polyfill loading already has tests so no other changes are necessary.

Bug

  • Related issues linked using fixes #number
  • Integration 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

Removes the extra webpack handling that was previously done, this ensures the file which is already minified and compiled does not get passed through minification again.

Largely based on vercel#21418
Closes vercel#21418

Co-Authored-By: Joe Haddad <timer150@gmail.com>
@ijjk

This comment has been minimized.

@styfle styfle requested a review from sokra Jul 29, 2021
@ijjk

This comment has been minimized.

assetMap.polyfillFiles = compilationAssets
.filter((p) => {
// Ensure only .js files are passed through
if (!p.name.endsWith('.js')) {
Copy link
Member

@styfle styfle Aug 13, 2021

Choose a reason for hiding this comment

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

Do we need to think about .cjs or .mjs here?

Copy link
Member Author

@timneutkens timneutkens Aug 13, 2021

Choose a reason for hiding this comment

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

Not currently, if an output like that is added then yes.

styfle
styfle approved these changes Aug 13, 2021
ijjk
ijjk approved these changes Aug 13, 2021
@ijjk

This comment has been minimized.

@ijjk
Copy link
Member

ijjk commented Aug 13, 2021

Stats from current PR

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
buildDuration 13.7s 12.6s -1.1s
buildDurationCached 3.2s 3.2s -55ms
nodeModulesSize 49.1 MB 49.1 MB ⚠️ +8.54 kB
Page Load Tests Overall increase ✓
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
/ failed reqs 0 0
/ total time (seconds) 2.519 2.512 -0.01
/ avg req/sec 992.51 995.07 +2.56
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.361 1.36 0
/error-in-render avg req/sec 1837.38 1838.67 +1.29
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
745.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.2 kB 42.2 kB
main-HASH.js gzip 23.1 kB 23.1 kB
webpack-HASH.js gzip 1.5 kB 1.44 kB -63 B
Overall change 67 kB 67 kB -63 B
Legacy Client Bundles (polyfills) Overall decrease ✓
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
polyfills-HASH.js gzip 31.1 kB N/A N/A
polyfills-a4..dd70.js gzip N/A 31 kB N/A
Overall change 31.1 kB 31 kB -77 B
Client Pages
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
_app-HASH.js gzip 980 B 980 B
_error-HASH.js gzip 194 B 194 B
amp-HASH.js gzip 312 B 312 B
css-HASH.js gzip 329 B 329 B
dynamic-HASH.js gzip 2.64 kB 2.64 kB
head-HASH.js gzip 350 B 350 B
hooks-HASH.js gzip 904 B 904 B
image-HASH.js gzip 4.13 kB 4.13 kB
index-HASH.js gzip 261 B 261 B
link-HASH.js gzip 1.66 kB 1.66 kB
routerDirect..HASH.js gzip 319 B 319 B
script-HASH.js gzip 387 B 387 B
withRouter-HASH.js gzip 320 B 320 B
bb14e60e810b..30f.css gzip 125 B 125 B
Overall change 12.9 kB 12.9 kB
Client Build Manifests
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
_buildManifest.js gzip 491 B 491 B
Overall change 491 B 491 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
index.html gzip 533 B 541 B ⚠️ +8 B
link.html gzip 546 B 553 B ⚠️ +7 B
withRouter.html gzip 525 B 534 B ⚠️ +9 B
Overall change 1.6 kB 1.63 kB ⚠️ +24 B

Diffs

Diff for polyfills-HASH.js
deleted
Diff for polyfills-a4..124eadd70.js

Diff too large to display

Diff for webpack-HASH.js
@@ -175,22 +175,6 @@
       /******/
     };
     /******/
-  })(); /* webpack/runtime/global */
-  /******/
-
-  /******/ /******/ !(function() {
-    /******/ __webpack_require__.g = (function() {
-      /******/ if (typeof globalThis === "object") return globalThis;
-      /******/ try {
-        /******/ return this || new Function("return this")();
-        /******/
-      } catch (e) {
-        /******/ if (typeof window === "object") return window;
-        /******/
-      }
-      /******/
-    })();
-    /******/
   })(); /* webpack/runtime/hasOwnProperty shorthand */
   /******/
Diff for index.html
@@ -8,10 +8,10 @@
     <script
       defer=""
       nomodule=""
-      src="/_next/static/chunks/polyfills-e87f09c84badadba76ef.js"
+      src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-031adeaf444149491045.js"
+      src="/_next/static/chunks/webpack-47f60bc5ff0cf5dfe268.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -8,10 +8,10 @@
     <script
       defer=""
       nomodule=""
-      src="/_next/static/chunks/polyfills-e87f09c84badadba76ef.js"
+      src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-031adeaf444149491045.js"
+      src="/_next/static/chunks/webpack-47f60bc5ff0cf5dfe268.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -8,10 +8,10 @@
     <script
       defer=""
       nomodule=""
-      src="/_next/static/chunks/polyfills-e87f09c84badadba76ef.js"
+      src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-031adeaf444149491045.js"
+      src="/_next/static/chunks/webpack-47f60bc5ff0cf5dfe268.js"
       defer=""
     ></script>
     <script

Webpack 4 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
buildDuration 11.4s 10.5s -899ms
buildDurationCached 4.5s 4.2s -252ms
nodeModulesSize 49.1 MB 49.1 MB ⚠️ +8.54 kB
Page Load Tests Overall increase ✓
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
/ failed reqs 0 0
/ total time (seconds) 2.598 2.495 -0.1
/ avg req/sec 962.25 1001.87 +39.62
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.384 1.408 ⚠️ +0.02
/error-in-render avg req/sec 1806.58 1774.94 ⚠️ -31.64
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
17.HASH.js gzip 185 B 186 B ⚠️ +1 B
677f882d2ed8..HASH.js gzip 14 kB 14 kB
framework.HASH.js gzip 41.9 kB 41.9 kB
main-HASH.js gzip 10.6 kB 10.6 kB
webpack-HASH.js gzip 1.19 kB 1.19 kB ⚠️ +1 B
Overall change 67.9 kB 67.9 kB ⚠️ +2 B
Legacy Client Bundles (polyfills) Overall decrease ✓
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
polyfills-HASH.js gzip 31.3 kB N/A N/A
polyfills-a4..dd70.js gzip N/A 31 kB N/A
Overall change 31.3 kB 31 kB -236 B
Client Pages Overall decrease ✓
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
_app-HASH.js gzip 965 B 965 B
_error-HASH.js gzip 3.71 kB 3.71 kB
amp-HASH.js gzip 552 B 552 B
css-HASH.js gzip 333 B 333 B
dynamic-HASH.js gzip 2.83 kB 2.83 kB -1 B
head-HASH.js gzip 2.97 kB 2.97 kB
hooks-HASH.js gzip 911 B 911 B
index-HASH.js gzip 231 B 231 B
link-HASH.js gzip 1.64 kB 1.64 kB
routerDirect..HASH.js gzip 298 B 298 B
script-HASH.js gzip 2.95 kB 2.95 kB
withRouter-HASH.js gzip 294 B 294 B
e025d2764813..52f.css gzip 125 B 125 B
Overall change 17.8 kB 17.8 kB -1 B
Client Build Manifests Overall decrease ✓
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
_buildManifest.js gzip 498 B 497 B -1 B
Overall change 498 B 497 B -1 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary timneutkens/next.js add/remove-next-polyfill-compilation Change
index.html gzip 578 B 585 B ⚠️ +7 B
link.html gzip 591 B 598 B ⚠️ +7 B
withRouter.html gzip 570 B 579 B ⚠️ +9 B
Overall change 1.74 kB 1.76 kB ⚠️ +23 B

Diffs

Diff for _buildManifest.js
@@ -10,7 +10,7 @@ self.__BUILD_MANIFEST = {
     "static\u002Fchunks\u002Fpages\u002Fcss-0fc40b547d044664b6a0.js"
   ],
   "/dynamic": [
-    "static\u002Fchunks\u002Fpages\u002Fdynamic-97a9156f97752a73abfb.js"
+    "static\u002Fchunks\u002Fpages\u002Fdynamic-03610522cdfd6f22239b.js"
   ],
   "/head": ["static\u002Fchunks\u002Fpages\u002Fhead-abecfbe6a75f8cfa32c0.js"],
   "/hooks": [
Diff for dynamic-HASH.js
@@ -574,7 +574,7 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
       var DynamicHello = next_dynamic__WEBPACK_IMPORTED_MODULE_1___default()(
         function() {
           return __webpack_require__
-            .e(/* import() */ 17)
+            .e(/* import() */ 16)
             .then(__webpack_require__.bind(null, "GaDq"));
         },
         {
Diff for 17.HASH.js
@@ -1,5 +1,5 @@
 (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
-  [17],
+  [16],
   {
     /***/ GaDq: /***/ function(
       module,
Diff for polyfills-HASH.js
deleted
Diff for polyfills-a4..124eadd70.js

Diff too large to display

Diff for webpack-HASH.js
@@ -85,7 +85,7 @@
       "static/chunks/" +
       ({}[chunkId] || chunkId) +
       "." +
-      { "17": "3d084653b6499a5a6e00" }[chunkId] +
+      { "16": "6fd1a3665a4372e3b214" }[chunkId] +
       ".js"
     );
     /******/
Diff for index.html
@@ -8,10 +8,10 @@
     <script
       defer=""
       nomodule=""
-      src="/_next/static/chunks/polyfills-85918dace37a5ba0ac6b.js"
+      src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-0cd6603d8fc22ae04472.js"
+      src="/_next/static/chunks/webpack-1d12e847dc26f509cc34.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -8,10 +8,10 @@
     <script
       defer=""
       nomodule=""
-      src="/_next/static/chunks/polyfills-85918dace37a5ba0ac6b.js"
+      src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-0cd6603d8fc22ae04472.js"
+      src="/_next/static/chunks/webpack-1d12e847dc26f509cc34.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -8,10 +8,10 @@
     <script
       defer=""
       nomodule=""
-      src="/_next/static/chunks/polyfills-85918dace37a5ba0ac6b.js"
+      src="/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js"
     ></script>
     <script
-      src="/_next/static/chunks/webpack-0cd6603d8fc22ae04472.js"
+      src="/_next/static/chunks/webpack-1d12e847dc26f509cc34.js"
       defer=""
     ></script>
     <script
Commit: 13e9131

@kodiakhq kodiakhq bot merged commit eddf205 into vercel:canary Aug 13, 2021
31 checks passed
@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants