Skip to content

Commit 0e3b271

Browse files
Merge branch 'canary' into add/tracing-improvements
2 parents cf6fa45 + 5313426 commit 0e3b271

File tree

288 files changed

+2019
-565
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

288 files changed

+2019
-565
lines changed

.github/workflows/build_native.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ jobs:
5050
uses: actions/cache@v2
5151
with:
5252
path: packages/next/native/**
53-
key: next-swc-nightly-2021-03-25-${{ matrix.target }}-${{ hashFiles('packages/next/build/swc/**') }}
53+
key: next-swc-nightly-2021-03-25-${{ matrix.target }}-${{ hashFiles('.github/workflows/build_native.yml', 'packages/next/build/swc/**') }}
54+
- name: Cross build aarch64 setup
55+
if: ${{ matrix.target == 'aarch64-apple-darwin' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
56+
run: |
57+
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
58+
export CC=$(xcrun -f clang);
59+
export CXX=$(xcrun -f clang++);
60+
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
61+
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
5462
- name: 'Build'
5563
if: steps.binary-cache.outputs.cache-hit != true
5664
run: yarn build-native --target ${{ matrix.target }}

.github/workflows/build_test_deploy.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ on:
88
name: Build, test, and deploy
99

1010
jobs:
11+
check-examples:
12+
name: Check examples
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Install moreutils
17+
run: sudo apt install moreutils
18+
- name: Check examples
19+
run: ./scripts/check-examples.sh
20+
1121
build:
1222
runs-on: ubuntu-latest
1323
env:
@@ -58,13 +68,15 @@ jobs:
5868
path: ./*
5969
key: ${{ github.sha }}
6070
- uses: actions/download-artifact@v2
71+
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
6172
with:
6273
name: next-swc-binaries
6374
path: packages/next/build/swc/dist
6475
# Only check linux build for now, mac builds can sometimes be different even with the same code
6576
- run: |
6677
mv ./packages/next/build/swc/dist/next-swc.linux-x64-gnu.node \
6778
./packages/next/native/next-swc.linux-x64-gnu.node
79+
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
6880
- run: ./scripts/check-pre-compiled.sh
6981
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
7082

@@ -305,45 +317,64 @@ jobs:
305317

306318
steps:
307319
- uses: actions/checkout@v2
320+
with:
321+
fetch-depth: 25
322+
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
323+
id: docs-change
308324
- name: Setup node
309325
uses: actions/setup-node@v2
326+
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
310327
with:
311328
node-version: 14
312329
check-latest: true
313330
- name: Install
314331
uses: actions-rs/toolchain@v1
332+
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
315333
with:
316334
profile: minimal
317335
toolchain: nightly-2021-03-25
318336
target: ${{ matrix.target }}
319337
- name: Cache cargo registry
320338
uses: actions/cache@v1
339+
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
321340
with:
322341
path: ~/.cargo/registry
323342
key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
324343
- name: Cache cargo index
325344
uses: actions/cache@v1
345+
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
326346
with:
327347
path: ~/.cargo/git
328348
key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
329349
- name: Cache native binary
330350
id: binary-cache
331351
uses: actions/cache@v2
352+
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
332353
with:
333354
path: packages/next/native/next-swc.*.node
334-
key: next-swc-nightly-2021-03-25-${{ matrix.target }}-${{ hashFiles('packages/next/build/swc/**') }}
355+
key: next-swc-nightly-2021-03-25-${{ matrix.target }}-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
356+
- name: Cross build aarch64 setup
357+
if: ${{ matrix.target == 'aarch64-apple-darwin' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
358+
run: |
359+
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
360+
export CC=$(xcrun -f clang);
361+
export CXX=$(xcrun -f clang++);
362+
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
363+
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
335364
- name: 'Build'
336-
if: steps.binary-cache.outputs.cache-hit != 'true'
365+
if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
337366
run: yarn build-native --target ${{ matrix.target }}
338367
env:
339368
MACOSX_DEPLOYMENT_TARGET: '10.13'
340369
working-directory: packages/next
341370
- name: Upload artifact
342371
uses: actions/upload-artifact@v2
372+
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
343373
with:
344374
name: next-swc-binaries
345375
path: packages/next/native/next-swc.*.node
346376
- name: Clear the cargo caches
377+
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
347378
run: |
348379
cargo install cargo-cache --no-default-features --features ci-autoclean
349380
cargo-cache
@@ -354,9 +385,15 @@ jobs:
354385

355386
steps:
356387
- uses: actions/checkout@v2
388+
with:
389+
fetch-depth: 25
390+
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
391+
id: docs-change
357392
- name: Install
393+
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
358394
uses: actions-rs/toolchain@v1
359395
with:
360396
toolchain: nightly-2021-03-25
361397
profile: minimal
362398
- run: cd packages/next/build/swc && cargo test
399+
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}

docs/api-reference/next.config.js/react-strict-mode.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ description: The complete Next.js runtime is now Strict Mode-compliant, learn ho
66

77
> **Suggested**: We strongly suggest you enable Strict Mode in your Next.js application to better prepare your application for the future of React.
88
9-
The Next.js runtime is now Strict Mode-compliant. To opt-in to Strict Mode, configure the following option in your `next.config.js`:
9+
React's [Strict Mode](https://reactjs.org/docs/strict-mode.html) is a development mode only feature for highlighting potential problems in an application. It helps to identify unsafe lifecycles, legacy API usage, and a number of other features.
10+
11+
The Next.js runtime is Strict Mode-compliant. To opt-in to Strict Mode, configure the following option in your `next.config.js`:
1012

1113
```js
1214
// next.config.js
@@ -15,9 +17,7 @@ module.exports = {
1517
}
1618
```
1719

18-
If you or your team are not ready to use Strict Mode in your entire application, that's OK! You can incrementally migrate on a page-by-page basis [using `<React.StrictMode>`](https://reactjs.org/docs/strict-mode.html).
19-
20-
React's Strict Mode is a development mode only feature for highlighting potential problems in an application. It helps to identify unsafe lifecycles, legacy API usage, and a number of other features.
20+
If you or your team are not ready to use Strict Mode in your entire application, that's OK! You can incrementally migrate on a page-by-page basis using `<React.StrictMode>`.
2121

2222
## Related
2323

docs/api-reference/next/image.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ Other properties on the `<Image />` component will be passed to the underlying
263263
- `ref`. Use [`onLoadingComplete`](#onloadingcomplete) instead.
264264
- `decoding`. It is always `"async"`.
265265

266+
## Styling
267+
268+
`next/image` wraps the `img` element with other `div` elements to maintain the aspect ratio of the image and prevent [Cumulative Layout Shift](https://vercel.com/blog/core-web-vitals#cumulative-layout-shift).
269+
270+
To add styles to the underlying `img` element, pass the `className` prop to the `<Image />` component. Then, use Next.js' [built-in CSS support](/docs/basic-features/built-in-css-support.md) to add rules to that class.
271+
272+
**Note:** If using [`layout="fill"`](/docs/api-reference/next/image.md#layout), ensure the parent element uses `position: relative`.
273+
266274
## Related
267275

268276
For more information on what to do next, we recommend the following sections:

docs/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const Profile = ({ user }) => {
101101
export default Profile
102102
```
103103

104-
An advantage of this pattern is preventing a flash of unauthenticated content before redirecting. It's important to note fetching user data in `getServerSideProps` will block rendering until the request to your authentication provider resolves. To prevent creating a bottleneck and decreasing your TTFB ([Time to First Byte](https://web.dev/time-to-first-byte/)), you should ensure your authentication lookup is fast. Otherwise, consider [static generation](#authenticating-statically-generated-pages).
104+
An advantage of this pattern is preventing a flash of unauthenticated content before redirecting. It's important to note fetching user data in `getServerSideProps` will block rendering until the request to your authentication provider resolves. To prevent creating a bottleneck and increasing your TTFB ([Time to First Byte](https://web.dev/time-to-first-byte/)), you should ensure your authentication lookup is fast. Otherwise, consider [static generation](#authenticating-statically-generated-pages).
105105

106106
## Authentication Providers
107107

docs/basic-features/data-fetching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ export async function getStaticPaths() {
424424
paths: [
425425
{ params: { ... } } // See the "paths" section below
426426
],
427-
fallback: true or false // See the "fallback" section below
427+
fallback: true, false, or 'blocking' // See the "fallback" section below
428428
};
429429
}
430430
```

errors/manifest.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,25 @@
427427
"title": "sharp-missing-in-production",
428428
"path": "/errors/sharp-missing-in-production.md"
429429
},
430+
{
431+
"title": "script-in-document-page",
432+
"path": "/errors/no-script-in-document-page.md"
433+
},
434+
{
435+
"title": "script-in-head-component",
436+
"path": "/errors/no-script-in-head-component.md"
437+
},
430438
{
431439
"title": "max-custom-routes-reached",
432440
"path": "/errors/max-custom-routes-reached.md"
433441
},
434442
{
435443
"title": "module-not-found",
436444
"path": "/errors/module-not-found.md"
445+
},
446+
{
447+
"title": "next-config-error",
448+
"path": "/errors/next-config-error.md"
437449
}
438450
]
439451
}

errors/next-config-error.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# next.config.js Loading Error
2+
3+
#### Why This Error Occurred
4+
5+
When attempting to load your `next.config.js` file an error occurred. This could be due to a syntax error or attempting to `require` a module that wasn't available.
6+
7+
#### Possible Ways to Fix It
8+
9+
See the error message in your terminal where you started `next` to see more context. The `next.config.js` file is not transpiled by Next.js currently so ensure only features supported by your current node.js version are being used.
10+
11+
### Useful Links
12+
13+
- [next.config.js documentation](https://nextjs.org/docs/api-reference/next.config.js/introduction)
14+
- [node.js version feature chart](https://node.green/)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Script component inside \_document.js
2+
3+
#### Why This Error Occurred
4+
5+
You can't use the `next/script` component inside the `_document.js` page. That's because the `_document.js` page only runs on the server and `next/script` has client-side functionality to ensure loading order.
6+
7+
#### Possible Ways to Fix It
8+
9+
If you want a global script, instead use the `_app.js` page.
10+
11+
```jsx
12+
import Script from 'next/script'
13+
14+
function MyApp({ Component, pageProps }) {
15+
return (
16+
<>
17+
<Script src="/my-script.js" />
18+
<Component {...pageProps} />
19+
</>
20+
)
21+
}
22+
23+
export default MyApp
24+
```
25+
26+
- [custom-app](https://nextjs.org/docs/advanced-features/custom-app)
27+
- [next-script](https://nextjs.org/docs/basic-features/script#usage)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Script component inside Head component
2+
3+
#### Why This Error Occurred
4+
5+
The `next/script` component shouldn't be placed inside the `next/head` component
6+
7+
#### Possible Ways to Fix It
8+
9+
Move the `<Script />` component outside of `<Head>...</Head>`
10+
11+
**Before**
12+
13+
```js
14+
import Script from 'next/script'
15+
import Head from 'next/head'
16+
17+
export default function Index() {
18+
return (
19+
<Head>
20+
<title>Next.js</title>
21+
<Script src="/my-script.js" />
22+
</Head>
23+
)
24+
}
25+
```
26+
27+
**After**
28+
29+
```js
30+
import Script from 'next/script'
31+
import Head from 'next/head'
32+
33+
export default function Index() {
34+
return (
35+
<>
36+
<Head>
37+
<title>Next.js</title>
38+
</Head>
39+
<Script src="/my-script.js" />
40+
</>
41+
)
42+
}
43+
```
44+
45+
### Useful links
46+
47+
- [next/head](https://nextjs.org/docs/api-reference/next/head)
48+
- [next/script](https://nextjs.org/docs/basic-features/script#usage)

0 commit comments

Comments
 (0)