-
Notifications
You must be signed in to change notification settings - Fork 26k
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
Exclude development from static html/json render on data request #44523
Conversation
As found by @alexkirsz this caused the HTML rendering to happen in development even for data requests of static pages, which is not needed because the incremental cache doesn't apply in development. Additional updated the launch.json to not say `launch app` given that it might be confused with the `app` directory.
Stats from current PRDefault Build (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack)
Legacy Client Bundles (polyfills)
Client Pages
Client Build Manifests
Rendered Page Sizes
Edge SSR bundle Size Overall increase
|
vercel/next.js canary | timneutkens/next.js fix/bypass-html-in-dev | Change | |
---|---|---|---|
edge-ssr.js gzip | 110 kB | 110 kB | ✓ |
page.js gzip | 98.4 kB | 98.4 kB | |
Overall change | 209 kB | 209 kB |
Middleware size Overall increase ⚠️
vercel/next.js canary | timneutkens/next.js fix/bypass-html-in-dev | Change | |
---|---|---|---|
middleware-b..fest.js gzip | 581 B | 582 B | |
middleware-r..fest.js gzip | 145 B | 145 B | ✓ |
middleware.js gzip | 27 kB | 27 kB | ✓ |
edge-runtime..pack.js gzip | 1.83 kB | 1.83 kB | ✓ |
Overall change | 29.6 kB | 29.6 kB |
Diffs
Diff for page.js
@@ -8618,7 +8618,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
/***/
},
- /***/ 6738: /***/ (
+ /***/ 1036: /***/ (
__unused_webpack_module,
__unused_webpack_exports,
__webpack_require__
@@ -8627,10 +8627,10 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
__webpack_require__.bind(__webpack_require__, 1210)
);
Promise.resolve(/* import() eager */).then(
- __webpack_require__.bind(__webpack_require__, 6448)
+ __webpack_require__.bind(__webpack_require__, 2973)
);
Promise.resolve(/* import() eager */).then(
- __webpack_require__.bind(__webpack_require__, 2973)
+ __webpack_require__.bind(__webpack_require__, 6448)
);
Promise.resolve(/* import() eager */).then(
__webpack_require__.bind(__webpack_require__, 9916)
Diff for middleware-b..-manifest.js
@@ -9,7 +9,7 @@ self.__BUILD_MANIFEST = {
rootMainFiles: [
"static/chunks/webpack-c452a3e31b73f504.js",
"static/chunks/152-792c0b16c9234019.js",
- "static/chunks/main-app-41573aefc84f5f2e.js"
+ "static/chunks/main-app-c9a0aaff35eafcb5.js"
],
pages: {
"/": [
Diff for main-app-HASH.js
@@ -1,7 +1,7 @@
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
[744],
{
- /***/ 2938: /***/ function(
+ /***/ 9915: /***/ function(
__unused_webpack_module,
__unused_webpack_exports,
__webpack_require__
@@ -10,10 +10,10 @@
__webpack_require__.t.bind(__webpack_require__, 429, 23)
);
Promise.resolve(/* import() eager */).then(
- __webpack_require__.t.bind(__webpack_require__, 8138, 23)
+ __webpack_require__.t.bind(__webpack_require__, 1161, 23)
);
Promise.resolve(/* import() eager */).then(
- __webpack_require__.t.bind(__webpack_require__, 1161, 23)
+ __webpack_require__.t.bind(__webpack_require__, 8138, 23)
);
Promise.resolve(/* import() eager */).then(
__webpack_require__.t.bind(__webpack_require__, 9379, 23)
@@ -28,7 +28,7 @@
return __webpack_require__((__webpack_require__.s = moduleId));
};
/******/ __webpack_require__.O(0, [152], function() {
- return __webpack_exec__(7070), __webpack_exec__(2938);
+ return __webpack_exec__(7070), __webpack_exec__(9915);
});
/******/ var __webpack_exports__ = __webpack_require__.O();
/******/ _N_E = __webpack_exports__;
@@ -1057,7 +1057,8 @@ export async function renderToHTML( | |||
|
|||
// Avoid rendering page un-necessarily for getServerSideProps data request | |||
// and getServerSideProps/getStaticProps redirects | |||
if ((isDataReq && !isSSG) || (renderOpts as any).isRedirect) { | |||
// In development the incrementalCache is not used so we short-circuit bypassing the html rendering. | |||
if ((isDataReq && (!isSSG || dev)) || (renderOpts as any).isRedirect) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm does the benefit of avoiding rendering here in dev offset the potential downside that a rendering error isn't caught?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's specifically needed as Turbopack handles data requests differently in that the team implemented a reverse of the getStaticProps/getServerSideProps tree shaking transform to allow better HMR of getStaticProps/getServerSideProps changes. So you end up with a file that doesn't have the component code, only the code used in getStaticProps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like that will need to be changed soon as we're changing how turbopack is handled and wouldn't work in production.
Based on #2968 This builds upon #2968 and @ForsakenHarmony's work on data routes to enable page data HMR. Page data HMR is a bit more clever than it is in Next.js as we won't re-render a Node.js result for each page file update. Instead, thanks to the `StripPageDefaultExport` transform, there are three versions of the page chunks: * client-side (strips page data exports); * server-side (full); * data server-side (strips page default export). Instead of subscribing to the full server-side result, on hydration, the client-side page separately subscribes to: * client-side updates (already the case); * data server-side updates (new). This means that updating something that only affects the page component will only cause a client-side update and **no Node.js re-rendering**, while updating something that only affects the data will only cause a server-side update. ~~I'm marking this as a draft for now as there are still a few areas to test/investigate:~~ - [x] When something that is used in both the default page export and data exports is changed, this will cause *two* HMR updates: one data update, and one client-side chunk update. **The same case breaks in Next.js, where we will receive a client-side update, but no server-side update, ending up with an incorrect result.** - [x] Differences between `getStaticProps/getServerSideProps`, as well as `getInitialProps` (need to talk with @timneutkens about this) (see vercel/next.js#44523) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Going to close this as we implemented a different solution. |
As found by @alexkirsz this caused the HTML rendering to happen in development even for data requests of static pages, which is not needed because the incremental cache doesn't apply in development.
Additional updated the launch.json to not say
launch app
given that it might be confused with theapp
directory.Bug
fixes #number
contributing.md
Feature
fixes #number
contributing.md
Documentation / Examples
pnpm build && pnpm lint