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

Keep custom app as non server component #37044

Merged
merged 8 commits into from
May 20, 2022
Merged

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented May 19, 2022

We added custom _app as server component support in #33149, but we found it's pretty confusing on usage like support it both server component pages and regular pages at the same time for having similar layout purpose.
When using the _app.server and _app at the same time, applying them into proper places become more confusing.
In that case, we decide to make _app.js can't be a server component, and you can still keep all the existing thing there. And also you don't need to think of the corresponding APIs of custom _app in RSC

  • Related issues linked using fixes #number
  • Integration tests added
  • Docs updated

@ijjk
Copy link
Member

ijjk commented May 19, 2022

Failing test suites

Commit: 43ff7de

yarn testheadless test/integration/cli/test/index.test.js

  • CLI Usage > info > should print output
Expand output

● CLI Usage › info › should print output

expect(received).toBe(expected) // Object.is equality

Expected: ""
Received: "warn  - Latest canary version not detected, detected: \"12.1.7-canary.10\", newest: \"12.1.7-canary.9\".
        Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
        Read more - https://nextjs.org/docs/messages/opening-an-issue
"

  496 |       // warning will show so skip this check for the stable release
  497 |       if (pkg.version.includes('-canary')) {
> 498 |         expect(info.stderr || '').toBe('')
      |                                   ^
  499 |       }
  500 |       expect(info.stdout).toMatch(
  501 |         new RegExp(`

  at Object.<anonymous> (integration/cli/test/index.test.js:498:35)

Read more about building and testing Next.js in contributing.md.

yarn testheadless test/integration/pnpm-support/test/index.test.js

  • pnpm support > should execute client-side JS on each page in outputStandalone
  • pnpm support > should execute client-side JS on each page
Expand output

● pnpm support › should execute client-side JS on each page in outputStandalone

Command npx pnpm run build failed with code 1

  33 |       }
  34 |       reject(
> 35 |         new Error(`Command ${cmd} ${args.join(' ')} failed with code ${code}`)
     |         ^
  36 |       )
  37 |     })
  38 |   })

  at ChildProcess.<anonymous> (integration/pnpm-support/test/index.test.js:35:9)

● pnpm support › should execute client-side JS on each page

Command npx pnpm run build failed with code 1

  33 |       }
  34 |       reject(
> 35 |         new Error(`Command ${cmd} ${args.join(' ')} failed with code ${code}`)
     |         ^
  36 |       )
  37 |     })
  38 |   })

  at ChildProcess.<anonymous> (integration/pnpm-support/test/index.test.js:35:9)

Read more about building and testing Next.js in contributing.md.

@ijjk
Copy link
Member

ijjk commented May 19, 2022

Stats from current PR

Default Build (Decrease detected ✓)
General Overall decrease ✓
vercel/next.js canary huozhi/next.js drop-app-server Change
buildDuration 14.4s 14.8s ⚠️ +324ms
buildDurationCached 6s 6s ⚠️ +53ms
nodeModulesSize 479 MB 479 MB -6.92 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary huozhi/next.js drop-app-server Change
/ failed reqs 0 0
/ total time (seconds) 3.563 3.842 ⚠️ +0.28
/ avg req/sec 701.74 650.64 ⚠️ -51.1
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.254 1.353 ⚠️ +0.1
/error-in-render avg req/sec 1993.96 1847.3 ⚠️ -146.66
Client Bundles (main, webpack) Overall decrease ✓
vercel/next.js canary huozhi/next.js drop-app-server Change
925.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42 kB 42 kB
main-HASH.js gzip 29 kB 29 kB -15 B
webpack-HASH.js gzip 1.44 kB 1.44 kB
Overall change 72.6 kB 72.6 kB -15 B
Legacy Client Bundles (polyfills)
vercel/next.js canary huozhi/next.js drop-app-server Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary huozhi/next.js drop-app-server Change
_app-HASH.js gzip 1.36 kB 1.36 kB
_error-HASH.js gzip 193 B 193 B
amp-HASH.js gzip 308 B 308 B
css-HASH.js gzip 327 B 327 B
dynamic-HASH.js gzip 2.71 kB 2.71 kB
head-HASH.js gzip 359 B 359 B
hooks-HASH.js gzip 920 B 920 B
image-HASH.js gzip 5.73 kB 5.73 kB
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 2.65 kB 2.65 kB
routerDirect..HASH.js gzip 320 B 320 B
script-HASH.js gzip 391 B 391 B
withRouter-HASH.js gzip 318 B 318 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 16 kB 16 kB
Client Build Manifests
vercel/next.js canary huozhi/next.js drop-app-server Change
_buildManifest.js gzip 458 B 458 B
Overall change 458 B 458 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary huozhi/next.js drop-app-server Change
index.html gzip 533 B 532 B -1 B
link.html gzip 547 B 546 B -1 B
withRouter.html gzip 528 B 527 B -1 B
Overall change 1.61 kB 1.6 kB -3 B

Diffs

Diff for main-HASH.js
@@ -622,34 +622,6 @@
         for (var i = 1; i < arguments.length; i++) _loop(i);
         return target;
       }
-      function _objectWithoutProperties(source, excluded) {
-        if (source == null) return {};
-        var target = _objectWithoutPropertiesLoose(source, excluded);
-        var key, i;
-        if (Object.getOwnPropertySymbols) {
-          var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
-          for (i = 0; i < sourceSymbolKeys.length; i++) {
-            key = sourceSymbolKeys[i];
-            if (excluded.indexOf(key) >= 0) continue;
-            if (!Object.prototype.propertyIsEnumerable.call(source, key))
-              continue;
-            target[key] = source[key];
-          }
-        }
-        return target;
-      }
-      function _objectWithoutPropertiesLoose(source, excluded) {
-        if (source == null) return {};
-        var target = {};
-        var sourceKeys = Object.keys(source);
-        var key, i;
-        for (i = 0; i < sourceKeys.length; i++) {
-          key = sourceKeys[i];
-          if (excluded.indexOf(key) >= 0) continue;
-          target[key] = source[key];
-        }
-        return target;
-      }
       var ReactDOM = false ? 0 : __webpack_require__(3935);
       var version = "12.1.7-canary.10";
       exports.version = version;
@@ -670,7 +642,6 @@
       var webpackHMR;
       var CachedApp, onPerfEntry;
       var CachedComponent;
-      var isRSCPage;
       var Container = /*#__PURE__*/ (function(_Component) {
         _inherits(Container, _Component);
         var _super = _createSuper(Container);
@@ -954,9 +925,8 @@
                       throw pageEntrypoint.error;
                     case 20:
                       CachedComponent = pageEntrypoint.component;
-                      isRSCPage = !!pageEntrypoint.exports.__next_rsc__;
                       if (true) {
-                        _ctx.next = 26;
+                        _ctx.next = 25;
                         break;
                       }
                       isValidElementType = Object(
@@ -969,7 +939,7 @@
                         })()
                       );
                       if (isValidElementType(CachedComponent)) {
-                        _ctx.next = 26;
+                        _ctx.next = 25;
                         break;
                       }
                       throw new Error(
@@ -978,24 +948,24 @@
                           '"'
                         )
                       );
-                    case 26:
-                      _ctx.next = 31;
+                    case 25:
+                      _ctx.next = 30;
                       break;
-                    case 28:
-                      _ctx.prev = 28;
+                    case 27:
+                      _ctx.prev = 27;
                       _ctx.t1 = _ctx["catch"](1);
                       // This catches errors like throwing in the top level of a module
                       initialErr = (0, _isError).getProperError(_ctx.t1);
-                    case 31:
+                    case 30:
                       if (false) {
                       }
                       if (!window.__NEXT_PRELOADREADY) {
-                        _ctx.next = 35;
+                        _ctx.next = 34;
                         break;
                       }
-                      _ctx.next = 35;
+                      _ctx.next = 34;
                       return window.__NEXT_PRELOADREADY(initialData.dynamicIds);
-                    case 35:
+                    case 34:
                       exports.router = router = (0, _router1).createRouter(
                         initialData.page,
                         initialData.query,
@@ -1036,21 +1006,21 @@
                           ? void 0
                           : opts.beforeRender)
                       ) {
-                        _ctx.next = 40;
+                        _ctx.next = 39;
                         break;
                       }
-                      _ctx.next = 40;
+                      _ctx.next = 39;
                       return opts.beforeRender();
-                    case 40:
+                    case 39:
                       render(renderCtx);
-                    case 41:
+                    case 40:
                     case "end":
                       return _ctx.stop();
                   }
               },
               _callee,
               null,
-              [[1, 28]]
+              [[1, 27]]
             );
           })
         );
@@ -1306,14 +1276,10 @@
         );
       }
       function renderApp(App, appProps) {
-        if (false) {
-          var Component, _, __, props;
-        } else {
-          return /*#__PURE__*/ _react.default.createElement(
-            App,
-            Object.assign({}, appProps)
-          );
-        }
+        return /*#__PURE__*/ _react.default.createElement(
+          App,
+          Object.assign({}, appProps)
+        );
       }
       var wrapApp = function(App) {
         return function(wrappedAppProps) {
Diff for index.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-3a9959a087b2af1c.js"
+      src="/_next/static/chunks/main-62e5c333d536c665.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-3a9959a087b2af1c.js"
+      src="/_next/static/chunks/main-62e5c333d536c665.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-3a9959a087b2af1c.js"
+      src="/_next/static/chunks/main-62e5c333d536c665.js"
       defer=""
     ></script>
     <script

Default Build with SWC (Decrease detected ✓)
General Overall decrease ✓
vercel/next.js canary huozhi/next.js drop-app-server Change
buildDuration 16.5s 16.6s ⚠️ +50ms
buildDurationCached 5.8s 5.8s ⚠️ +56ms
nodeModulesSize 479 MB 479 MB -6.92 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary huozhi/next.js drop-app-server Change
/ failed reqs 0 0
/ total time (seconds) 3.597 3.544 -0.05
/ avg req/sec 695.01 705.42 +10.41
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.242 1.275 ⚠️ +0.03
/error-in-render avg req/sec 2012.93 1961.06 ⚠️ -51.87
Client Bundles (main, webpack) Overall decrease ✓
vercel/next.js canary huozhi/next.js drop-app-server Change
925.HASH.js gzip 178 B 178 B
framework-HASH.js gzip 42.7 kB 42.7 kB
main-HASH.js gzip 29.5 kB 29.4 kB -21 B
webpack-HASH.js gzip 1.45 kB 1.45 kB
Overall change 73.8 kB 73.7 kB -21 B
Legacy Client Bundles (polyfills)
vercel/next.js canary huozhi/next.js drop-app-server Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary huozhi/next.js drop-app-server Change
_app-HASH.js gzip 1.35 kB 1.35 kB
_error-HASH.js gzip 179 B 179 B
amp-HASH.js gzip 311 B 311 B
css-HASH.js gzip 324 B 324 B
dynamic-HASH.js gzip 2.89 kB 2.89 kB
head-HASH.js gzip 357 B 357 B
hooks-HASH.js gzip 920 B 920 B
image-HASH.js gzip 5.82 kB 5.82 kB
index-HASH.js gzip 261 B 261 B
link-HASH.js gzip 2.78 kB 2.78 kB
routerDirect..HASH.js gzip 322 B 322 B
script-HASH.js gzip 392 B 392 B
withRouter-HASH.js gzip 317 B 317 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 16.3 kB 16.3 kB
Client Build Manifests
vercel/next.js canary huozhi/next.js drop-app-server Change
_buildManifest.js gzip 457 B 457 B
Overall change 457 B 457 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary huozhi/next.js drop-app-server Change
index.html gzip 532 B 532 B
link.html gzip 546 B 547 B ⚠️ +1 B
withRouter.html gzip 527 B 528 B ⚠️ +1 B
Overall change 1.6 kB 1.61 kB ⚠️ +2 B

Diffs

Diff for main-HASH.js
@@ -622,34 +622,6 @@
         for (var i = 1; i < arguments.length; i++) _loop(i);
         return target;
       }
-      function _objectWithoutProperties(source, excluded) {
-        if (source == null) return {};
-        var target = _objectWithoutPropertiesLoose(source, excluded);
-        var key, i;
-        if (Object.getOwnPropertySymbols) {
-          var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
-          for (i = 0; i < sourceSymbolKeys.length; i++) {
-            key = sourceSymbolKeys[i];
-            if (excluded.indexOf(key) >= 0) continue;
-            if (!Object.prototype.propertyIsEnumerable.call(source, key))
-              continue;
-            target[key] = source[key];
-          }
-        }
-        return target;
-      }
-      function _objectWithoutPropertiesLoose(source, excluded) {
-        if (source == null) return {};
-        var target = {};
-        var sourceKeys = Object.keys(source);
-        var key, i;
-        for (i = 0; i < sourceKeys.length; i++) {
-          key = sourceKeys[i];
-          if (excluded.indexOf(key) >= 0) continue;
-          target[key] = source[key];
-        }
-        return target;
-      }
       var ReactDOM = false ? 0 : __webpack_require__(3935);
       var version = "12.1.7-canary.10";
       exports.version = version;
@@ -670,7 +642,6 @@
       var webpackHMR;
       var CachedApp, onPerfEntry;
       var CachedComponent;
-      var isRSCPage;
       var Container = /*#__PURE__*/ (function(_Component) {
         _inherits(Container, _Component);
         var _super = _createSuper(Container);
@@ -954,9 +925,8 @@
                       throw pageEntrypoint.error;
                     case 20:
                       CachedComponent = pageEntrypoint.component;
-                      isRSCPage = !!pageEntrypoint.exports.__next_rsc__;
                       if (true) {
-                        _ctx.next = 26;
+                        _ctx.next = 25;
                         break;
                       }
                       isValidElementType = Object(
@@ -969,7 +939,7 @@
                         })()
                       );
                       if (isValidElementType(CachedComponent)) {
-                        _ctx.next = 26;
+                        _ctx.next = 25;
                         break;
                       }
                       throw new Error(
@@ -978,24 +948,24 @@
                           '"'
                         )
                       );
-                    case 26:
-                      _ctx.next = 31;
+                    case 25:
+                      _ctx.next = 30;
                       break;
-                    case 28:
-                      _ctx.prev = 28;
+                    case 27:
+                      _ctx.prev = 27;
                       _ctx.t1 = _ctx["catch"](1);
                       // This catches errors like throwing in the top level of a module
                       initialErr = (0, _isError).getProperError(_ctx.t1);
-                    case 31:
+                    case 30:
                       if (false) {
                       }
                       if (!window.__NEXT_PRELOADREADY) {
-                        _ctx.next = 35;
+                        _ctx.next = 34;
                         break;
                       }
-                      _ctx.next = 35;
+                      _ctx.next = 34;
                       return window.__NEXT_PRELOADREADY(initialData.dynamicIds);
-                    case 35:
+                    case 34:
                       exports.router = router = (0, _router1).createRouter(
                         initialData.page,
                         initialData.query,
@@ -1036,21 +1006,21 @@
                           ? void 0
                           : opts.beforeRender)
                       ) {
-                        _ctx.next = 40;
+                        _ctx.next = 39;
                         break;
                       }
-                      _ctx.next = 40;
+                      _ctx.next = 39;
                       return opts.beforeRender();
-                    case 40:
+                    case 39:
                       render(renderCtx);
-                    case 41:
+                    case 40:
                     case "end":
                       return _ctx.stop();
                   }
               },
               _callee,
               null,
-              [[1, 28]]
+              [[1, 27]]
             );
           })
         );
@@ -1306,14 +1276,10 @@
         );
       }
       function renderApp(App, appProps) {
-        if (false) {
-          var Component, _, __, props;
-        } else {
-          return /*#__PURE__*/ _react.default.createElement(
-            App,
-            Object.assign({}, appProps)
-          );
-        }
+        return /*#__PURE__*/ _react.default.createElement(
+          App,
+          Object.assign({}, appProps)
+        );
       }
       var wrapApp = function(App) {
         return function(wrappedAppProps) {
Diff for index.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-3a9959a087b2af1c.js"
+      src="/_next/static/chunks/main-62e5c333d536c665.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-3a9959a087b2af1c.js"
+      src="/_next/static/chunks/main-62e5c333d536c665.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-3a9959a087b2af1c.js"
+      src="/_next/static/chunks/main-62e5c333d536c665.js"
       defer=""
     ></script>
     <script
Commit: 121ceb2

@huozhi huozhi marked this pull request as ready for review May 19, 2022 22:39
@kodiakhq kodiakhq bot merged commit d25e246 into vercel:canary May 20, 2022
@huozhi huozhi deleted the drop-app-server branch May 20, 2022 18:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 20, 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.

3 participants