Skip to content

Commit

Permalink
Merge branch 'update-examples-readmes' of https://github.com/vercel/n…
Browse files Browse the repository at this point in the history
…ext.js into update-examples-readmes
  • Loading branch information
Nutlope committed Mar 16, 2022
2 parents 693689c + 947f5a5 commit e213684
Show file tree
Hide file tree
Showing 539 changed files with 13,061 additions and 3,725 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Expand Up @@ -25,6 +25,7 @@ packages/next-codemod/**/*.d.ts
packages/next-env/**/*.d.ts
packages/create-next-app/templates/**
test/integration/eslint/**
test/integration/script-loader/**/*
test/development/basic/legacy-decorators/**/*
test/production/emit-decorator-metadata/**/*.js
test-timings.json
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.json
Expand Up @@ -15,7 +15,7 @@
"jsx": true
},
"babelOptions": {
"presets": ["@babel/preset-env", "@babel/preset-react"],
"presets": ["next/babel"],
"caller": {
// Eslint supports top level await when a parser for it is included. We enable the parser by default for Babel.
"supportsTopLevelAwait": true
Expand Down
139 changes: 112 additions & 27 deletions .github/workflows/build_test_deploy.yml
Expand Up @@ -97,7 +97,7 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
profile: minimal
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
components: rustfmt, clippy

- name: Cache cargo registry
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

Expand Down Expand Up @@ -241,6 +241,52 @@ jobs:
name: Run test/development
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

- name: Upload test trace
if: always()
uses: actions/upload-artifact@v2
with:
name: test-trace
if-no-files-found: ignore
retention-days: 2
path: |
test/traces
testDevE2E:
name: Test Development (E2E)
runs-on: ubuntu-latest
needs: [build, build-native-dev]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

- run: echo ${{needs.build.outputs.docsChange}}

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off

- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}

- uses: actions/download-artifact@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
name: next-swc-dev-binary
path: packages/next-swc/native

- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

- run: NEXT_TEST_MODE=dev node run-tests.js --type e2e
name: Run test/e2e (dev)
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
Expand All @@ -265,7 +311,7 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

Expand Down Expand Up @@ -295,6 +341,42 @@ jobs:
name: Run test/production
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

testProdE2E:
name: Test Production (E2E)
runs-on: ubuntu-latest
needs: [build, build-native-dev]
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

- run: echo ${{needs.build.outputs.docsChange}}

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off

- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}

- uses: actions/download-artifact@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
name: next-swc-dev-binary
path: packages/next-swc/native

- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

- run: NEXT_TEST_MODE=start node run-tests.js --type e2e
name: Run test/e2e (production)
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
Expand All @@ -310,11 +392,11 @@ jobs:
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6]
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

Expand All @@ -331,6 +413,10 @@ jobs:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}

- uses: pnpm/action-setup@v2.2.1
with:
version: 6.32.2

- uses: actions/download-artifact@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
Expand All @@ -340,7 +426,7 @@ jobs:
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

- run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/6
- run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/18
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

- name: Upload test trace
Expand All @@ -364,7 +450,7 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

Expand Down Expand Up @@ -414,7 +500,7 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

Expand Down Expand Up @@ -449,7 +535,7 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

Expand Down Expand Up @@ -493,7 +579,7 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

Expand Down Expand Up @@ -530,7 +616,7 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 17
check-latest: true
Expand Down Expand Up @@ -563,7 +649,7 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14

Expand Down Expand Up @@ -598,7 +684,6 @@ jobs:
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{ steps.docs-change.outputs.docsChange != 'docs only change' }}
with:
node-version: 14

Expand Down Expand Up @@ -647,7 +732,7 @@ jobs:
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
profile: minimal
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23

- name: Cache cargo registry
uses: actions/cache@v2
Expand Down Expand Up @@ -726,7 +811,7 @@ jobs:
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
profile: minimal
- run: cd packages/next-swc && cargo test
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
Expand Down Expand Up @@ -804,8 +889,8 @@ jobs:
# Node.js in Baidu need to compatible with `GLIBC_2.12`
build: >-
set -e &&
rustup toolchain install nightly-2021-11-15 &&
rustup default nightly-2021-11-15 &&
rustup toolchain install nightly-2022-02-23 &&
rustup default nightly-2022-02-23 &&
rustup target add x86_64-unknown-linux-gnu &&
npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 &&
turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 &&
Expand All @@ -815,8 +900,8 @@ jobs:
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: >-
set -e &&
rustup toolchain install nightly-2021-11-15 &&
rustup default nightly-2021-11-15 &&
rustup toolchain install nightly-2022-02-23 &&
rustup default nightly-2022-02-23 &&
rustup target add x86_64-unknown-linux-musl &&
npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 &&
turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl &&
Expand All @@ -837,8 +922,8 @@ jobs:
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig
build: >-
set -e &&
rustup toolchain install nightly-2021-11-15 &&
rustup default nightly-2021-11-15 &&
rustup toolchain install nightly-2022-02-23 &&
rustup default nightly-2022-02-23 &&
rustup target add aarch64-unknown-linux-gnu &&
npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 &&
turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 &&
Expand Down Expand Up @@ -878,8 +963,8 @@ jobs:
build: >-
set -e &&
npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 &&
rustup toolchain install nightly-2021-11-15 &&
rustup default nightly-2021-11-15 &&
rustup toolchain install nightly-2022-02-23 &&
rustup default nightly-2022-02-23 &&
rustup target add aarch64-unknown-linux-musl &&
turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-musl &&
llvm-strip -x packages/next-swc/native/next-swc.*.node
Expand Down Expand Up @@ -945,7 +1030,7 @@ jobs:
with:
profile: minimal
override: true
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
target: ${{ matrix.settings.target }}

- name: Cache cargo registry
Expand Down Expand Up @@ -1007,7 +1092,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
override: true
target: wasm32-unknown-unknown

Expand Down Expand Up @@ -1063,7 +1148,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
override: true
target: wasm32-unknown-unknown

Expand Down
30 changes: 30 additions & 0 deletions docs/advanced-features/compiler.md
Expand Up @@ -189,6 +189,36 @@ First, update to the latest version of Next.js: `npm install next@latest`. Then,

## Experimental Features

### Emotion

We're working to port `@emotion/babel-plugin` to the Next.js Compiler.

First, update to the latest version of Next.js: `npm install next@latest`. Then, update your `next.config.js` file:

```js
// next.config.js

module.exports = {
experimental: {
emotion: boolean | {
// default is true. It will be disabled when build type is production.
sourceMap?: boolean,
// default is 'dev-only'.
autoLabel?: 'never' | 'dev-only' | 'always',
// default is '[local]'.
// Allowed values: `[local]` `[filename]` and `[dirname]`
// This option only works when autoLabel is set to 'dev-only' or 'always'.
// It allows you to define the format of the resulting label.
// The format is defined via string where variable parts are enclosed in square brackets [].
// For example labelFormat: "my-classname--[local]", where [local] will be replaced with the name of the variable the result is assigned to.
labelFormat?: string,
},
},
}
```

Only `importMap` in `@emotion/babel-plugin` is not supported for now.

### Minification

You can opt-in to using the Next.js compiler for minification. This is 7x faster than Terser.
Expand Down
2 changes: 2 additions & 0 deletions docs/advanced-features/custom-app.md
Expand Up @@ -40,6 +40,8 @@ The `Component` prop is the active `page`, so whenever you navigate between rout

`pageProps` is an object with the initial props that were preloaded for your page by one of our [data fetching methods](/docs/basic-features/data-fetching/overview.md), otherwise it's an empty object.

The `App.getInitialProps` receives a single argument called `context.ctx`. It's an object with the same set of properties as the [`context` object](/docs/api-reference/data-fetching/get-initial-props#context-object) in `getInitialProps`.

### Caveats

- If your app is running and you added a custom `App`, you'll need to restart the development server. Only required if `pages/_app.js` didn't exist before.
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced-features/custom-document.md
Expand Up @@ -41,7 +41,7 @@ Or add a `className` to the `body` tag:
## Caveats

- The `<Head />` component used in `_document` is not the same as [`next/head`](/docs/api-reference/next/head.md). The `<Head />` component used here should only be used for any `<head>` code that is common for all pages. For all other cases, such as `<title>` tags, we recommend using [`next/head`](/docs/api-reference/next/head.md) in your pages or components.
- React components outside of `<Main />` will not be initialized by the browser. Do _not_ add application logic here or custom CSS (like `styled-jsx`). If you need shared components in all your pages (like a menu or a toolbar), read [Layouts](/docs/basic-features/layouts.md) intead.
- React components outside of `<Main />` will not be initialized by the browser. Do _not_ add application logic here or custom CSS (like `styled-jsx`). If you need shared components in all your pages (like a menu or a toolbar), read [Layouts](/docs/basic-features/layouts.md) instead.
- `Document` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/overview.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md).

## Customizing `renderPage`
Expand Down

0 comments on commit e213684

Please sign in to comment.