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

Stop using environment variables in pages/_document #31946

Merged
merged 4 commits into from
Nov 30, 2021

Conversation

devknoll
Copy link
Contributor

@devknoll devknoll commented Nov 30, 2021

Since #31939 is going to move the Document components, we can't rely on DefinePlugin to provide environment variables. This PR passes them as render opts instead. We can't just force this to be bundled like e.g. next/dynamic, because we use it internally.

@ijjk ijjk added created-by: Chrome Aurora PRs by the Google Chrome team: https://web.dev/aurora type: next labels Nov 30, 2021
@ijjk

This comment has been minimized.

@ijjk
Copy link
Member

ijjk commented Nov 30, 2021

Failing test suites

Commit: 84645cf

test/integration/image-optimization/test/index.test.js

  • Image optimization for serverless apps > On an SSR page > should preload exactly two eligible images
Expand output

● Image optimization for serverless apps › On an SSR page › should preload exactly two eligible images

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

Expected substring: "<link rel=\"preload\" href=\"main-image-1.jpg\" as=\"image\"/>"
Received string:    "<!DOCTYPE html><html><head><meta charSet=\"utf-8\"/><meta name=\"viewport\" content=\"width=device-width\"/><meta name=\"next-head-count\" content=\"2\"/><noscript data-n-css=\"\"></noscript><script defer=\"\" nomodule=\"\" src=\"/_next/static/chunks/polyfills-5cd94c89d3acac5f.js\"></script><script src=\"/_next/static/chunks/webpack-514908bffb652963.js\" defer=\"\"></script><script src=\"/_next/static/chunks/framework-87ce17455edff467.js\" defer=\"\"></script><script src=\"/_next/static/chunks/main-be9ba3f60c18a6e4.js\" defer=\"\"></script><script src=\"/_next/static/chunks/pages/_app-753628925edb8fac.js\" defer=\"\"></script><script src=\"/_next/static/chunks/pages/stars-35eb1ceaa6860a74.js\" defer=\"\"></script><script src=\"/_next/static/7lnkafKotQkv1X8ba3pgc/_buildManifest.js\" defer=\"\"></script><script src=\"/_next/static/7lnkafKotQkv1X8ba3pgc/_ssgManifest.js\" defer=\"\"></script><script src=\"/_next/static/7lnkafKotQkv1X8ba3pgc/_middlewareManifest.js\" defer=\"\"></script></head><body><div id=\"__next\" data-reactroot=\"\"><div class=\"container\"><main><div><link rel=\"preload\" href=\"already-preloaded.jpg\"/><img src=\"already-preloaded.jpg\"/><img src=\"tiny-image.jpg\" width=\"20\" height=\"20\"/><img src=\"vector-image.svg\"/><img src=\"hidden-image-1.jpg\" hidden=\"\"/><div hidden=\"\"><img src=\"hidden-image-2.jpg\"/></div><img src=\"main-image-1.jpg\"/><img src=\"main-image-2.jpg\"/><img src=\"main-image-3.jpg\"/><img src=\"main-image-4.jpg\"/><img src=\"main-image-5.jpg\"/></div><div>Next stars: <!-- -->446.4557170692114</div></main></div></div><script id=\"__NEXT_DATA__\" type=\"application/json\">{\"props\":{\"pageProps\":{\"stars\":446.4557170692114}},\"page\":\"/stars\",\"query\":{},\"buildId\":\"7lnkafKotQkv1X8ba3pgc\",\"runtimeConfig\":{},\"isFallback\":false,\"gip\":true,\"scriptLoader\":[]}</script></body></html>"

  48 |     let html = await renderViaHTTP(appPort, path)
  49 |     html = html.replace(
> 50 |       '<link rel="preload" href="already-preloaded.jpg" as="image"/>',
     |                      ^
  51 |       ''
  52 |     )
  53 |     expect(html).not.toContain(

  at Object.<anonymous> (integration/image-optimization/test/index.test.js:50:22)

@devknoll devknoll marked this pull request as ready for review November 30, 2021 02:03
@ijjk

This comment has been minimized.

@devknoll devknoll changed the title Stop using environment variables in pages/_document Stop using environment variables in pages/_document Nov 30, 2021
@ijjk
Copy link
Member

ijjk commented Nov 30, 2021

Stats from current PR

Default Build (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
buildDuration 16.9s 17.1s ⚠️ +249ms
buildDurationCached 3.2s 3.2s -26ms
nodeModulesSize 347 MB 347 MB ⚠️ +1.16 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
/ failed reqs 0 0
/ total time (seconds) 2.822 2.878 ⚠️ +0.06
/ avg req/sec 885.81 868.62 ⚠️ -17.19
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.319 1.363 ⚠️ +0.04
/error-in-render avg req/sec 1895.92 1833.91 ⚠️ -62.01
Client Bundles (main, webpack, commons)
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
450.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.2 kB 42.2 kB
main-HASH.js gzip 28.4 kB 28.4 kB
webpack-HASH.js gzip 1.45 kB 1.45 kB
Overall change 72.3 kB 72.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
_app-HASH.js gzip 1.37 kB 1.37 kB
_error-HASH.js gzip 194 B 194 B
amp-HASH.js gzip 312 B 312 B
css-HASH.js gzip 326 B 326 B
dynamic-HASH.js gzip 2.38 kB 2.38 kB
head-HASH.js gzip 350 B 350 B
hooks-HASH.js gzip 635 B 635 B
image-HASH.js gzip 4.45 kB 4.45 kB
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 1.87 kB 1.87 kB
routerDirect..HASH.js gzip 321 B 321 B
script-HASH.js gzip 383 B 383 B
withRouter-HASH.js gzip 318 B 318 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 13.3 kB 13.3 kB
Client Build Manifests
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
_buildManifest.js gzip 460 B 460 B
Overall change 460 B 460 B
Rendered Page Sizes
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
index.html gzip 532 B 532 B
link.html gzip 546 B 546 B
withRouter.html gzip 527 B 527 B
Overall change 1.6 kB 1.6 kB

Default Build with SWC (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
buildDuration 18.1s 18.2s ⚠️ +66ms
buildDurationCached 3.4s 3.2s -138ms
nodeModulesSize 347 MB 347 MB ⚠️ +1.16 kB
Page Load Tests Overall increase ✓
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
/ failed reqs 0 0
/ total time (seconds) 2.852 2.745 -0.11
/ avg req/sec 876.67 910.7 +34.03
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.329 1.345 ⚠️ +0.02
/error-in-render avg req/sec 1881.49 1858.25 ⚠️ -23.24
Client Bundles (main, webpack, commons)
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
450.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42.3 kB 42.3 kB
main-HASH.js gzip 28.6 kB 28.6 kB
webpack-HASH.js gzip 1.44 kB 1.44 kB
Overall change 72.5 kB 72.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
_app-HASH.js gzip 1.35 kB 1.35 kB
_error-HASH.js gzip 180 B 180 B
amp-HASH.js gzip 305 B 305 B
css-HASH.js gzip 321 B 321 B
dynamic-HASH.js gzip 2.37 kB 2.37 kB
head-HASH.js gzip 342 B 342 B
hooks-HASH.js gzip 622 B 622 B
image-HASH.js gzip 4.47 kB 4.47 kB
index-HASH.js gzip 256 B 256 B
link-HASH.js gzip 1.91 kB 1.91 kB
routerDirect..HASH.js gzip 314 B 314 B
script-HASH.js gzip 375 B 375 B
withRouter-HASH.js gzip 309 B 309 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 13.2 kB 13.2 kB
Client Build Manifests
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
_buildManifest.js gzip 459 B 459 B
Overall change 459 B 459 B
Rendered Page Sizes
vercel/next.js canary azukaru/next.js x-change-env-to-render-opts Change
index.html gzip 533 B 533 B
link.html gzip 545 B 545 B
withRouter.html gzip 526 B 526 B
Overall change 1.6 kB 1.6 kB
Commit: 0e8faa3

@kodiakhq kodiakhq bot merged commit 2b5d62d into vercel:canary Nov 30, 2021
@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Chrome Aurora PRs by the Google Chrome team: https://web.dev/aurora type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants