Skip to content

Commit

Permalink
Merge branch 'canary' into feature/storybook-default-import
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-burel committed Nov 17, 2020
2 parents 1b04b26 + 23111ca commit 8052b05
Show file tree
Hide file tree
Showing 611 changed files with 18,000 additions and 6,101 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ packages/next-codemod/**/*.js
packages/next-codemod/**/*.d.ts
packages/next-env/**/*.d.ts
test/integration/async-modules/**
test-timings.json
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/1.Bug_report.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
---
name: Bug report
about: Create a bug report for the Next.js core / examples
labels: 'template: bug'
---

<!-- NOTE: This template is not optional. If you remove it or leave out sections there is a high likelihood it will be moved to the GitHub Discussions "Help" section -->

# Bug report

## Describe the bug
Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/2.Feature_request.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
---
name: Feature request
about: Create a feature request for the Next.js core
labels: 'template: story'
---

<!-- NOTE: Feature requests will be converted to the GitHub Discussions "Ideas" section. -->

# Feature request

## Is your feature request related to a problem? Please describe.
Expand Down
57 changes: 50 additions & 7 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- run: yarn install --frozen-lockfile --check-files
- run: node run-tests.js --timings --write-timings -g 1/1
- uses: actions/cache@v2
id: cache-build
with:
Expand Down Expand Up @@ -46,8 +47,25 @@ jobs:
key: ${{ github.sha }}
- run: ./check-pre-compiled.sh

testAll:
name: Test All
testUnit:
name: Test Unit
runs-on: ubuntu-latest
needs: build
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
HEADLESS: true
steps:
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}

- run: node run-tests.js --timings --type unit -g 1/1

testIntegration:
name: Test Integration
runs-on: ubuntu-latest
needs: build
env:
Expand All @@ -68,7 +86,30 @@ jobs:
# TODO: remove after we fix watchpack watching too much
- run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- run: node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3
- run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3

testElectron:
name: Test Electron
runs-on: ubuntu-latest
needs: build
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
HEADLESS: true
TEST_ELECTRON: 1
steps:
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}

# TODO: remove after we fix watchpack watching too much
- run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- run: yarn add -W --dev [email protected] [email protected]

- run: xvfb-run node run-tests.js test/integration/with-electron/test/index.test.js

testYarnPnP:
runs-on: ubuntu-latest
Expand All @@ -92,7 +133,7 @@ jobs:
testsPass:
name: thank you, next
runs-on: ubuntu-latest
needs: [lint, checkPrecompiled, testAll, testYarnPnP]
needs: [lint, checkPrecompiled, testIntegration, testUnit, testYarnPnP]
steps:
- run: exit 0

Expand All @@ -107,10 +148,12 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- run: cat packages/next/package.json | jq '.resolutions.webpack = "^5.0.0-beta.30"' > package.json.tmp && mv package.json.tmp packages/next/package.json
- run: cat packages/next/package.json | jq '.resolutions.react = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp packages/next/package.json
- run: cat packages/next/package.json | jq '.resolutions."react-dom" = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp packages/next/package.json
- run: cat package.json | jq '.resolutions.webpack = "^5.0.0-beta.30"' > package.json.tmp && mv package.json.tmp package.json
- run: cat package.json | jq '.resolutions.react = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json
- run: cat package.json | jq '.resolutions."react-dom" = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json
- run: yarn install --check-files
- run: yarn list webpack react react-dom
- run: node run-tests.js test/integration/link-ref/test/index.test.js
- run: node run-tests.js test/integration/production/test/index.test.js
- run: node run-tests.js test/integration/basic/test/index.test.js
- run: node run-tests.js test/integration/async-modules/test/index.test.js
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ examples/**/out
examples/**/.env*.local

pr-stats.md
test-timings.json

# Vercel
.vercel
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ packages/next-codemod/transforms/__testfixtures__/**/*
packages/next-codemod/transforms/__tests__/**/*
packages/next-codemod/**/*.js
packages/next-codemod/**/*.d.ts
packages/next-env/**/*.d.ts
packages/next-env/**/*.d.ts
test-timings.json
163 changes: 105 additions & 58 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,111 @@ variables:
NEXT_TELEMETRY_DISABLED: '1'
node_version: ^10.10.0

jobs:
- job: test_ie11
pool:
vmImage: 'windows-2019'
steps:
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: 'Install Node.js'
stages:
- stage: Build
jobs:
- job: build
pool:
vmImage: 'windows-2019'
steps:
- script: echo $(Agent.BuildDirectory)
- script: dir
- script: dir $(System.DefaultWorkingDirectory)
- script: echo $(Build.SourceVersion)
- powershell: Get-MpComputerStatus
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: 'Install Node.js'
- task: Cache@2
inputs:
# use deterministic cache key that is specific
# to this test run
key: $(Build.SourceVersion)
path: $(System.DefaultWorkingDirectory)
displayName: Cache Build
- script: |
yarn install --frozen-lockfile --check-files
displayName: 'Install dependencies'
- script: |
node run-tests.js --timings --write-timings --azure -g 1/1
displayName: 'Fetch test timing data'
- task: CacheBeta@0
inputs:
key: yarn | $(Agent.OS) | yarn.lock
path: $(YARN_CACHE_FOLDER)
displayName: Cache Yarn packages
- stage: Test
dependsOn: Build
jobs:
- job: test_ie11_production
pool:
vmImage: 'windows-2019'
steps:
- checkout: none
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: 'Install Node.js'
- task: Cache@2
inputs:
# use deterministic cache key that is specific
# to this test run
key: $(Build.SourceVersion)
path: $(System.DefaultWorkingDirectory)
displayName: Cache Build
- script: |
yarn testie --forceExit test/integration/production/
displayName: 'Run tests'
- script: |
yarn install --frozen-lockfile --check-files
displayName: 'Install dependencies'
- job: test_unit
pool:
vmImage: 'windows-2019'
steps:
- checkout: none
- script: |
wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
displayName: 'List Chrome version'
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: 'Install Node.js'
- task: Cache@2
inputs:
# use deterministic cache key that is specific
# to this test run
key: $(Build.SourceVersion)
path: $(System.DefaultWorkingDirectory)
displayName: Cache Build
- script: |
node run-tests.js -g 1/1 --timings --azure --type unit
displayName: 'Run tests'
- script: |
yarn testie --forceExit test/integration/production/
displayName: 'Run tests'
- job: test_chrome
pool:
vmImage: 'windows-2019'
strategy:
maxParallel: 10
matrix:
node-10-1:
group: 1/4
node-10-2:
group: 2/4
node-10-3:
group: 3/4
node-10-4:
group: 4/4
steps:
- script: |
wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
displayName: 'List Chrome version'
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: 'Install Node.js'

- task: CacheBeta@0
inputs:
key: yarn | $(Agent.OS) | yarn.lock
path: $(YARN_CACHE_FOLDER)
displayName: Cache Yarn packages

- script: |
yarn install --frozen-lockfile --check-files
displayName: 'Install dependencies'
- script: |
node run-tests.js -g $(group) --timings --azure
displayName: 'Run tests'
- job: test_chrome_integration
pool:
vmImage: 'windows-2019'
strategy:
matrix:
node-10-1:
group: 1/4
node-10-2:
group: 2/4
node-10-3:
group: 3/4
node-10-4:
group: 4/4
steps:
- checkout: none
- script: |
wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
displayName: 'List Chrome version'
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: 'Install Node.js'
- task: Cache@2
inputs:
# use deterministic cache key that is specific
# to this test run
key: $(Build.SourceVersion)
path: $(System.DefaultWorkingDirectory)
displayName: Cache Build
- script: |
node run-tests.js -g $(group) --timings --azure
displayName: 'Run tests'
2 changes: 0 additions & 2 deletions docs/advanced-features/automatic-static-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ And if you add `getServerSideProps` to the page, it will then be JavaScript, lik
.next/server/static/${BUILD_ID}/about.js
```

In development you'll know if `pages/about.js` is optimized or not thanks to the included [static optimization indicator](/docs/api-reference/next.config.js/static-optimization-indicator.md).

## Caveats

- If you have a [custom `App`](/docs/advanced-features/custom-app.md) with `getInitialProps` then this optimization will be turned off in pages without [Static Generation](/docs/basic-features/data-fetching.md#getstaticprops-static-generation).
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced-features/customizing-babel-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ description: Extend the babel preset added by Next.js with your own configs.
</ul>
</details>

Next.js includes the `next/babel` preset to your app, it includes everything needed to compile React applications and server-side code. But if you want to extend the default Babel configs, it's also possible.
Next.js includes the `next/babel` preset to your app, which includes everything needed to compile React applications and server-side code. But if you want to extend the default Babel configs, it's also possible.

To start, you only need to define a `.babelrc` file at the top of your app, if such file is found, we're going to consider it the _source of truth_, therefore it needs to define what Next.js needs as well, which is the `next/babel` preset.
To start, you only need to define a `.babelrc` file at the top of your app. If such a file is found, it will be considered as the _source of truth_, and therefore it needs to define what Next.js needs as well, which is the `next/babel` preset.

Here's an example `.babelrc` file:

Expand Down
25 changes: 24 additions & 1 deletion docs/advanced-features/i18n-routing.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
description: Next.js has built-in support for internationalized routing and language detection. Learn more here.
---

# Internationalized Routing

<details>
Expand Down Expand Up @@ -87,7 +91,7 @@ By using domain routing you can configure locales to be served from different do
// next.config.js
module.exports = {
i18n: {
locales: ['en-US', 'fr', 'nl-NL'],
locales: ['en-US', 'fr', 'nl-NL', 'nl-BE'],
defaultLocale: 'en-US',

domains: [
Expand All @@ -102,6 +106,9 @@ module.exports = {
{
domain: 'example.nl',
defaultLocale: 'nl-NL',
// specify other locales that should be redirected
// to this domain
locales: ['nl-BE'],
},
],
},
Expand All @@ -113,6 +120,7 @@ For example if you have `pages/blog.js` the following urls will be available:
- `example.com/blog`
- `example.fr/blog`
- `example.nl/blog`
- `example.nl/nl-BE/blog`

## Automatic Locale Detection

Expand All @@ -127,6 +135,21 @@ When using Domain Routing, if a user with the `Accept-Language` header `fr;q=0.9

When using Sub-path Routing, the user would be redirected to `/fr`.

### Disabling Automatic Locale Detection

The automatic locale detection can be disabled with:

```js
// next.config.js
module.exports = {
i18n: {
localeDetection: false,
},
}
```

When `localeDetection` is set to `false` Next.js will no longer automatically redirect based on the user's preferred locale and will only provide locale information detected from either the locale based domain or locale path as described above.

## Accessing the locale information

You can access the locale information via the Next.js router. For example, using the [`useRouter()`](https://nextjs.org/docs/api-reference/next/router#userouter) hook the following properties are available:
Expand Down
Loading

0 comments on commit 8052b05

Please sign in to comment.