Skip to content

Commit

Permalink
Merge branch 'canary' into fix/yarn-pnp-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jan 13, 2022
2 parents d794a87 + 5d2730b commit 27c84ba
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 63 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-static-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export async function getStaticProps({ params }) {
export default Post
```

## getStaticProps with TypeScript
## getStaticPaths with TypeScript

For TypeScript, you can use the `GetStaticPaths` type from `next`:

Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/data-fetching/client-side.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The team behind Next.js has created a React hook library for data fetching calle

Using the same example as above, we can now use SWR to fetch the profile data. SWR will automatically cache the data for us and will revalidate the data if it becomes stale.

For more information on using SWR, check out the [SWR docs](https://swr.vercel.app/docs).
For more information on using SWR, check out the [SWR docs](https://swr.vercel.app/docs/getting-started).

```jsx
import useSWR from 'swr'
Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/data-fetching/get-server-side-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Take the following example. An API route is used to fetch some data from a CMS.

## Fetching data on the client side

If your page contains frequently updating data, and you don’t need to pre-render the data, you can fetch the data on the [client side](/docs/basic-features/client-side.md). An example of this is user-specific data:
If your page contains frequently updating data, and you don’t need to pre-render the data, you can fetch the data on the [client side](/docs/basic-features/data-fetching/client-side.md). An example of this is user-specific data:

- First, immediately show the page without data. Parts of the page can be pre-rendered using Static Generation. You can show loading states for missing data.
- Then, fetch the data on the client side and display it when ready.
Expand Down
6 changes: 4 additions & 2 deletions docs/basic-features/data-fetching/get-static-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ You should use `getStaticProps` if:
- The data can be publicly cached (not user-specific)
- The page must be pre-rendered (for SEO) and be very fast — `getStaticProps` generates `HTML` and `JSON` files, both of which can be cached by a CDN for performance

Because `getStaticProps` runs at build time, it does **not** receive data that’s only available during request time, such as query parameters or `HTTP` headers, as it generates static `HTML`. When combined with [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md) however, it will run in the background while the stale page is being revalidated, and the fresh page served to the browser.
When combined with [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md), `getStaticProps` will run in the background while the stale page is being revalidated, and the fresh page served to the browser.

Because `getStaticProps` runs at build time, it does **not** have access to the incoming request (such as query parameters or `HTTP` headers) as it generates static `HTML`. If you need access to the request for your page, consider using [Middleware](/docs/middleware.md) in addition to `getStaticProps`.

## Using getStaticProps to fetch data from a CMS

Expand Down Expand Up @@ -76,7 +78,7 @@ Alternatively, if you are **not** using API routes to fetch data, then the [`fet

To verify what Next.js eliminates from the client-side bundle, you can use the [next-code-elimination tool](https://next-code-elimination.vercel.app/).

## Statically Generates both HTML and JSON
## Statically generates both HTML and JSON

When a page with `getStaticProps` is pre-rendered at build time, in addition to the page HTML file, Next.js generates a JSON file holding the result of running `getStaticProps`.

Expand Down
4 changes: 2 additions & 2 deletions docs/basic-features/font-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ By default, Next.js will automatically inline font CSS at build time, eliminatin
```js
// Before
<link
href="https://fonts.googleapis.com/css2?family=Inter"
href="https://fonts.googleapis.com/css2?family=Inter&display=optional"
rel="stylesheet"
/>

// After
<style data-href="https://fonts.googleapis.com/css2?family=Inter">
<style data-href="https://fonts.googleapis.com/css2?family=Inter&display=optional">
@font-face{font-family:'Inter';font-style:normal...
</style>
```
Expand Down
2 changes: 1 addition & 1 deletion license.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Vercel, Inc.
Copyright (c) 2022 Vercel, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/license.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Vercel, Inc.
Copyright (c) 2022 Vercel, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/license.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Vercel, Inc.
Copyright (c) 2022 Vercel, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 4 additions & 1 deletion packages/next/build/polyfills/process.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
module.exports = global.process || require('../../compiled/process')
module.exports =
global.process?.env && typeof global.process?.env === 'object'
? global.process
: require('../../compiled/process')
2 changes: 1 addition & 1 deletion packages/next/compiled/nanoid/index.cjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(()=>{var e={113:e=>{"use strict";e.exports=require("crypto")},240:(e,r,t)=>{let l=t(113);let{urlAlphabet:a}=t(294);const n=32;let _,u;let random=e=>{if(!_||_.length<e){_=Buffer.allocUnsafe(e*n);l.randomFillSync(_);u=0}else if(u+e>_.length){l.randomFillSync(_);u=0}let r=_.subarray(u,u+e);u+=e;return r};let customRandom=(e,r,t)=>{let l=(2<<31-Math.clz32(e.length-1|1))-1;let a=Math.ceil(1.6*l*r/e.length);return()=>{let n="";while(true){let _=t(a);let u=a;while(u--){n+=e[_[u]&l]||"";if(n.length===r)return n}}}};let customAlphabet=(e,r)=>customRandom(e,r,random);let nanoid=(e=21)=>{let r=random(e);let t="";while(e--){t+=a[r[e]&63]}return t};e.exports={nanoid:nanoid,customAlphabet:customAlphabet,customRandom:customRandom,urlAlphabet:a,random:random}},294:e=>{let r="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";e.exports={urlAlphabet:r}}};var r={};function __nccwpck_require__(t){var l=r[t];if(l!==undefined){return l.exports}var a=r[t]={exports:{}};var n=true;try{e[t](a,a.exports,__nccwpck_require__);n=false}finally{if(n)delete r[t]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(240);module.exports=t})();
(()=>{var e={113:e=>{"use strict";e.exports=require("crypto")},240:(e,r,t)=>{let l=t(113);let{urlAlphabet:a}=t(294);const n=128;let _,u;let fillPool=e=>{if(!_||_.length<e){_=Buffer.allocUnsafe(e*n);l.randomFillSync(_);u=0}else if(u+e>_.length){l.randomFillSync(_);u=0}u+=e};let random=e=>{fillPool(e);return _.subarray(u-e,u)};let customRandom=(e,r,t)=>{let l=(2<<31-Math.clz32(e.length-1|1))-1;let a=Math.ceil(1.6*l*r/e.length);return()=>{let n="";while(true){let _=t(a);let u=a;while(u--){n+=e[_[u]&l]||"";if(n.length===r)return n}}}};let customAlphabet=(e,r)=>customRandom(e,r,random);let nanoid=(e=21)=>{fillPool(e);let r="";for(let t=u-e;t<u;t++){r+=a[_[t]&63]}return r};e.exports={nanoid:nanoid,customAlphabet:customAlphabet,customRandom:customRandom,urlAlphabet:a,random:random}},294:e=>{let r="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";e.exports={urlAlphabet:r}}};var r={};function __nccwpck_require__(t){var l=r[t];if(l!==undefined){return l.exports}var a=r[t]={exports:{}};var n=true;try{e[t](a,a.exports,__nccwpck_require__);n=false}finally{if(n)delete r[t]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(240);module.exports=t})();
2 changes: 1 addition & 1 deletion packages/next/compiled/postcss-safe-parser/safe-parse.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/compiled/postcss-scss/scss-syntax.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/license.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Vercel, Inc.
Copyright (c) 2022 Vercel, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"caniuse-lite": "^1.0.30001283",
"jest-worker": "27.0.0-next.5",
"node-fetch": "2.6.1",
"postcss": "8.2.15",
"postcss": "8.4.5",
"react-is": "17.0.2",
"react-refresh": "0.8.3",
"stream-browserify": "3.0.0",
Expand Down Expand Up @@ -218,7 +218,7 @@
"lru-cache": "5.1.1",
"micromatch": "4.0.4",
"mini-css-extract-plugin": "2.4.3",
"nanoid": "3.1.20",
"nanoid": "3.1.30",
"native-url": "0.3.4",
"neo-async": "2.6.1",
"node-html-parser": "1.4.9",
Expand Down
7 changes: 7 additions & 0 deletions test/integration/polyfills/pages/process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Page() {
return (
<div id="process">
Hello, {process.env.NEXT_PUBLIC_VISITOR ?? 'stranger'}
</div>
)
}
13 changes: 11 additions & 2 deletions test/integration/polyfills/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ describe('Polyfills', () => {
await browser.close()
})

it('should allow using process.env when there is an element with `id` of `process`', async () => {
const browser = await webdriver(appPort, '/process')
const text = await browser.elementByCss('#process').text()

expect(text).toBe('Hello, stranger')

await browser.close()
})

it('should contain generated page count in output', async () => {
expect(output).toContain('Generating static pages (0/4)')
expect(output).toContain('Generating static pages (4/4)')
expect(output).toContain('Generating static pages (0/5)')
expect(output).toContain('Generating static pages (5/5)')
// we should only have 1 segment and the initial message logged out
expect(output.match(/Generating static pages/g).length).toBe(5)
})
Expand Down
60 changes: 16 additions & 44 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7342,11 +7342,6 @@ colorette@^1.2.1:
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b"
integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==

colorette@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94"
integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==

colors@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.5.tgz#89c7ad9a374bc030df8013241f68136ed8835afc"
Expand Down Expand Up @@ -14290,20 +14285,10 @@ nan@^2.12.1, nan@^2.13.2:
version "2.14.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"

nanoid@3.1.20, nanoid@^3.1.20:
version "3.1.20"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788"
integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==

nanoid@^3.1.22:
version "3.1.22"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.22.tgz#b35f8fb7d151990a8aebd5aa5015c03cf726f844"
integrity sha512-/2ZUaJX2ANuLtTvqTlgqBQNJoQO398KyJgZloL0PZkC0dpysjncRUPsFe3DUPzz/y3h+u7C46np8RMuvF3jsSQ==

nanoid@^3.1.23:
version "3.1.23"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.23.tgz#f744086ce7c2bc47ee0a8472574d5c78e4183a81"
integrity sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==
nanoid@3.1.30, nanoid@^3.1.30:
version "3.1.30"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.30.tgz#63f93cc548d2a113dc5dfbc63bfa09e2b9b64362"
integrity sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==

nanomatch@^1.2.9:
version "1.2.13"
Expand Down Expand Up @@ -16460,14 +16445,14 @@ postcss@7.0.32, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.11, postcss@^7.0.14
source-map "^0.6.1"
supports-color "^6.1.0"

postcss@8.2.15:
version "8.2.15"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.15.tgz#9e66ccf07292817d226fc315cbbf9bc148fbca65"
integrity sha512-2zO3b26eJD/8rb106Qu2o7Qgg52ND5HPjcyQiK2B98O388h43A448LCslC0dI2P97wCAQRJsFvwTRcXxTKds+Q==
postcss@8.4.5, postcss@^8.2.1, postcss@^8.2.7:
version "8.4.5"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.5.tgz#bae665764dfd4c6fcc24dc0fdf7e7aa00cc77f95"
integrity sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg==
dependencies:
colorette "^1.2.2"
nanoid "^3.1.23"
source-map "^0.6.1"
nanoid "^3.1.30"
picocolors "^1.0.0"
source-map-js "^1.0.1"

postcss@^5.0.10:
version "5.2.18"
Expand All @@ -16486,24 +16471,6 @@ postcss@^6.0.0, postcss@^6.0.9:
source-map "^0.6.1"
supports-color "^5.4.0"

postcss@^8.2.1:
version "8.2.1"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.1.tgz#eabc5557c4558059b9d9e5b15bce7ffa9089c2a8"
integrity sha512-RhsqOOAQzTgh1UB/IZdca7F9WDb7SUCR2Vnv1x7DbvuuggQIpoDwjK+q0rzoPffhYvWNKX5JSwS4so4K3UC6vA==
dependencies:
colorette "^1.2.1"
nanoid "^3.1.20"
source-map "^0.6.1"

postcss@^8.2.7:
version "8.2.10"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.10.tgz#ca7a042aa8aff494b334d0ff3e9e77079f6f702b"
integrity sha512-b/h7CPV7QEdrqIxtAf2j31U5ef05uBDuvoXv6L51Q4rcS1jdlXAVKJv+atCFdUXYl9dyTHGyoMzIepwowRJjFw==
dependencies:
colorette "^1.2.2"
nanoid "^3.1.22"
source-map "^0.6.1"

pre-commit@1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/pre-commit/-/pre-commit-1.2.2.tgz#dbcee0ee9de7235e57f79c56d7ce94641a69eec6"
Expand Down Expand Up @@ -18365,6 +18332,11 @@ source-list-map@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"

source-map-js@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.1.tgz#a1741c131e3c77d048252adfa24e23b908670caf"
integrity sha512-4+TN2b3tqOCd/kaGRJ/sTYA0tR0mdXx26ipdolxcwtJVqEnqNYvlCAt1q3ypy4QMlYus+Zh34RNtYLoq2oQ4IA==

source-map-resolve@^0.5.0:
version "0.5.3"
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a"
Expand Down

0 comments on commit 27c84ba

Please sign in to comment.