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

Prebundle react for appDir #41337

Merged
merged 44 commits into from Oct 18, 2022
Merged

Prebundle react for appDir #41337

merged 44 commits into from Oct 18, 2022

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Oct 11, 2022

Inline a react and react-dom for app dir, when appDir flag is enabled opt into the built-in version for all.

For server layer react, use the react share subset for server components.
For all server side of react-dom usage, use the server-rendering-stub.

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team type: next labels Oct 11, 2022
@ijjk
Copy link
Member

ijjk commented Oct 12, 2022

Failing test suites

Commit: 19a6e5d

pnpm testheadless test/e2e/app-dir/app-static.test.ts

  • app-dir static/dynamic handling > should handle dynamicParams: false correctly
  • app-dir static/dynamic handling > should handle dynamicParams: true correctly
  • app-dir static/dynamic handling > should navigate to static path correctly
  • app-dir static/dynamic handling > should ssr dynamically when detected automatically with fetch cache option
  • app-dir static/dynamic handling > should ssr dynamically when forced via config
Expand output

● app-dir static/dynamic handling › should handle dynamicParams: false correctly

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

Expected: 404
Received: 500

  162 |         { redirect: 'manual' }
  163 |       )
> 164 |       expect(invalidRes.status).toBe(404)
      |                                 ^
  165 |       expect(await invalidRes.text()).toContain('page could not be found')
  166 |     }
  167 |   })

  at Object.<anonymous> (e2e/app-dir/app-static.test.ts:164:33)

● app-dir static/dynamic handling › should handle dynamicParams: true correctly

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

Expected: 200
Received: 500

  222 |         }
  223 |       )
> 224 |       expect(res.status).toBe(200)
      |                          ^
  225 |       const html = await res.text()
  226 |       const $ = cheerio.load(html)
  227 |

  at Object.<anonymous> (e2e/app-dir/app-static.test.ts:224:26)

● app-dir static/dynamic handling › should navigate to static path correctly

expect(received).toContain(expected) // indexOf

Expected substring: "/blog/[author]"
Received string:    "<head></head><body><pre style=\"word-wrap: break-word; white-space: pre-wrap;\">Internal Server Error</pre></body>"

  235 |     await browser.eval('window.beforeNav = 1')
  236 |
> 237 |     expect(await browser.eval('document.documentElement.innerHTML')).toContain(
      |                                                                      ^
  238 |       '/blog/[author]'
  239 |     )
  240 |     await browser.elementByCss('#author-2').click()

  at Object.<anonymous> (e2e/app-dir/app-static.test.ts:237:70)

● app-dir static/dynamic handling › should ssr dynamically when detected automatically with fetch cache option

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

Expected: "/ssr-auto/cache-no-store"
Received: ""

  276 |     const initial$ = cheerio.load(initialHtml)
  277 |
> 278 |     expect(initial$('#page').text()).toBe(pathname)
      |                                      ^
  279 |     const initialDate = initial$('#date').text()
  280 |
  281 |     expect(initialHtml).toContain('Example Domain')

  at Object.<anonymous> (e2e/app-dir/app-static.test.ts:278:38)

● app-dir static/dynamic handling › should ssr dynamically when forced via config

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

Expected: "/ssr-forced"
Received: ""

  336 |     const initial$ = cheerio.load(initialHtml)
  337 |
> 338 |     expect(initial$('#page').text()).toBe('/ssr-forced')
      |                                      ^
  339 |     const initialDate = initial$('#date').text()
  340 |
  341 |     const secondRes = await fetchViaHTTP(next.url, '/ssr-forced', undefined, {

  at Object.<anonymous> (e2e/app-dir/app-static.test.ts:338:38)

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

pnpm testheadless test/e2e/app-dir/back-button-download-bug.test.ts

  • app-dir back button download bug > should redirect route when clicking link
Expand output

● app-dir back button download bug › should redirect route when clicking link

page.waitForSelector: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "#post-page"
============================================================

  329 |     return this.chain(() => {
  330 |       return page
> 331 |         .waitForSelector(selector, { timeout, state: 'attached' })
      |          ^
  332 |         .then(async (el) => {
  333 |           // it seems selenium waits longer and tests rely on this behavior
  334 |           // so we wait for the load event fire before returning

  at lib/browsers/playwright.ts:331:10
  at Object.<anonymous> (e2e/app-dir/back-button-download-bug.test.ts:34:18)

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

pnpm testheadless test/e2e/app-dir/prefetching.test.ts

  • app dir prefetching > should show layout eagerly when prefetched with loading one level down
  • app dir prefetching > should not have prefetch error for static path
Expand output

● app dir prefetching › should show layout eagerly when prefetched with loading one level down

next build failed with code/signal 1

  75 |         if (code || signal)
  76 |           reject(
> 77 |             new Error(`next build failed with code/signal ${code || signal}`)
     |             ^
  78 |           )
  79 |         else resolve()
  80 |       })

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:77:13)

● app dir prefetching › should not have prefetch error for static path

next build failed with code/signal 1

  75 |         if (code || signal)
  76 |           reject(
> 77 |             new Error(`next build failed with code/signal ${code || signal}`)
     |             ^
  78 |           )
  79 |         else resolve()
  80 |       })

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:77:13)

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

pnpm testheadless test/e2e/app-dir/rendering.test.ts

  • app dir rendering > ISR > should revalidate the page when revalidate is configured
  • app dir rendering > SSR only > should run data in layout and page
  • app dir rendering > SSR only > should run data in parallel
  • app dir rendering > static only > should run data in layout and page
  • app dir rendering > static only > should run data in parallel during development
Expand output

● app dir rendering › SSR only › should run data in layout and page

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

Expected: "hello from layout"
Received: ""

  39 |       const html = await renderViaHTTP(next.url, '/ssr-only/nested')
  40 |       const $ = cheerio.load(html)
> 41 |       expect($('#layout-message').text()).toBe('hello from layout')
     |                                           ^
  42 |       expect($('#page-message').text()).toBe('hello from page')
  43 |     })
  44 |

  at Object.<anonymous> (e2e/app-dir/rendering.test.ts:41:43)

● app dir rendering › SSR only › should run data in parallel

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

Expected: "hello from slow layout"
Received: ""

  52 |       // expect(duration < 7000).toBe(true)
  53 |       const $ = cheerio.load(html)
> 54 |       expect($('#slow-layout-message').text()).toBe('hello from slow layout')
     |                                                ^
  55 |       expect($('#slow-page-message').text()).toBe('hello from slow page')
  56 |     })
  57 |   })

  at Object.<anonymous> (e2e/app-dir/rendering.test.ts:54:48)

● app dir rendering › static only › should run data in layout and page

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

Expected: "hello from layout"
Received: ""

  61 |       const html = await renderViaHTTP(next.url, '/static-only/nested')
  62 |       const $ = cheerio.load(html)
> 63 |       expect($('#layout-message').text()).toBe('hello from layout')
     |                                           ^
  64 |       expect($('#page-message').text()).toBe('hello from page')
  65 |     })
  66 |

  at Object.<anonymous> (e2e/app-dir/rendering.test.ts:63:43)

● app dir rendering › static only › should run data in parallel during development

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

Expected: "hello from slow layout"
Received: ""

  78 |       // expect(duration < 7000).toBe(true)
  79 |       const $ = cheerio.load(html)
> 80 |       expect($('#slow-layout-message').text()).toBe('hello from slow layout')
     |                                                ^
  81 |       expect($('#slow-page-message').text()).toBe('hello from slow page')
  82 |     })
  83 |   })

  at Object.<anonymous> (e2e/app-dir/rendering.test.ts:80:48)

● app dir rendering › ISR › should revalidate the page when revalidate is configured

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

Expected: "hello from layout"
Received: ""

   95 |       }
   96 |       const { $ } = await getPage()
>  97 |       expect($('#layout-message').text()).toBe('hello from layout')
      |                                           ^
   98 |       expect($('#page-message').text()).toBe('hello from page')
   99 |
  100 |       const layoutNow = $('#layout-now').text()

  at Object.<anonymous> (e2e/app-dir/rendering.test.ts:97:43)

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

@huozhi huozhi mentioned this pull request Oct 14, 2022
huozhi added a commit that referenced this pull request Oct 14, 2022
Since we have already bundled dependencies for server layer, so the
shared deps chunk group is not needed anymore.
Also changing to esm assets import with next internals for edge function
and middleware build.

The changes are originally from #41337, try to land them separately.
@huozhi huozhi marked this pull request as ready for review October 18, 2022 22:49
Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

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

Nice!

@ijjk ijjk merged commit bc335d7 into vercel:canary Oct 18, 2022
@huozhi huozhi deleted the app-prebundle-react branch October 18, 2022 23:45
ijjk added a commit that referenced this pull request Oct 22, 2022
reverting #41337

Co-authored-by: JJ Kasper <jj@jjsweb.site>
shuding pushed a commit to shuding/next.js that referenced this pull request Oct 23, 2022
reverting vercel#41337

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Kikobeats pushed a commit to Kikobeats/next.js that referenced this pull request Oct 24, 2022
Since we have already bundled dependencies for server layer, so the
shared deps chunk group is not needed anymore.
Also changing to esm assets import with next internals for edge function
and middleware build.

The changes are originally from vercel#41337, try to land them separately.
Kikobeats pushed a commit to Kikobeats/next.js that referenced this pull request Oct 24, 2022
Inline a react and react-dom for app dir, when `appDir` flag is enabled
opt into the built-in version for all.

For server layer react, use the react share subset for server
components.
For all server side of react-dom usage, use the server-rendering-stub.

Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application. created-by: Next.js team PRs by the Next.js team type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants