Skip to content

Commit

Permalink
Merge branch 'canary' into add/more-stats-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jul 16, 2021
2 parents ddab46e + 6e99f7a commit 23c6fdb
Show file tree
Hide file tree
Showing 42 changed files with 516 additions and 119 deletions.
2 changes: 2 additions & 0 deletions docs/api-reference/next.config.js/rewrites.md
Expand Up @@ -87,6 +87,8 @@ module.exports = {
}
```

Note: rewrites in `beforeFiles` do not check the filesystem/dynamic routes immediately after matching a source, they continue until all `beforeFiles` have been checked.

## Rewrite parameters

When using parameters in a rewrite the parameters will be passed in the query by default when none of the parameters are used in the `destination`.
Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/environment-variables.md
Expand Up @@ -110,7 +110,7 @@ Next.js allows you to set defaults in `.env` (all environments), `.env.developme

`.env.local` always overrides the defaults set.

> **Note**: `.env`, `.env.development`, and `.env.production` files should be included in your repository as they define defaults. **`.env*.local` should be added to `.gitignore`**, as those files are intended to be ignored. `.env.local` is where secrets can be stored.
> **Note**: `.env`, `.env.development`, and `.env.production` files should be included in your repository as they define defaults. **`.env.*.local` should be added to `.gitignore`**, as those files are intended to be ignored. `.env.local` is where secrets can be stored.
## Environment Variables on Vercel

Expand Down
12 changes: 12 additions & 0 deletions errors/manifest.json
Expand Up @@ -414,6 +414,18 @@
{
"title": "import-esm-externals",
"path": "/errors/import-esm-externals.md"
},
{
"title": "max-custom-routes-reached",
"path": "max-custom-routes-reached.md"
},
{
"title": "static-page-generation-timeout",
"path": "/errors/static-page-generation-timeout.md"
},
{
"title": "page-data-collection-timeout",
"path": "/errors/page-data-collection-timeout.md"
}
]
}
Expand Down
17 changes: 17 additions & 0 deletions errors/max-custom-routes-reached.md
@@ -0,0 +1,17 @@
# Max Custom Routes Reached

#### Why This Error Occurred

The number of combined routes from `headers`, `redirects`, and `rewrites` exceeds 1000. This can impact performance because each request will iterate over all routes to check for a match in the worst case.

#### Possible Ways to Fix It

- Leverage dynamic routes inside of the `pages` folder to reduce the number of rewrites needed
- Combine headers routes into dynamic matches e.g. `/first-header-route` `/second-header-route` -> `/(first-header-route$|second-header-route$)`

### Useful Links

- [Dynamic Routes documentation](https://nextjs.org/docs/routing/dynamic-routes)
- [Rewrites documentation](https://nextjs.org/docs/api-reference/next.config.js/rewrites)
- [Redirects documentation](https://nextjs.org/docs/api-reference/next.config.js/redirects)
- [Headers documentation](https://nextjs.org/docs/api-reference/next.config.js/headers)
18 changes: 18 additions & 0 deletions errors/page-data-collection-timeout.md
@@ -0,0 +1,18 @@
# Collecting page data timed out after multiple attempts

#### Why This Error Occurred

Next.js tries to restart the worker pool of the page data collection when no progress happens for a while, to avoid hanging builds.

When restarted it will retry all uncompleted jobs, but if a job was unsuccessfully attempted multiple times, this will lead to an error.

#### Possible Ways to Fix It

- Make sure that there is no infinite loop during execution.
- Make sure all Promises in `getStaticPaths` `resolve` or `reject` correctly.
- Avoid very long timeouts for network requests.
- Increase the timeout by changing the `experimental.pageDataCollectionTimeout` configuration option (default `60` in seconds).

### Useful Links

- [`getStaticPaths`](https://nextjs.org/docs/basic-features/data-fetching#getstaticpaths-static-generation)
18 changes: 18 additions & 0 deletions errors/static-page-generation-timeout.md
@@ -0,0 +1,18 @@
# Static page generation timed out after multiple attempts

#### Why This Error Occurred

Next.js tries to restart the worker pool of the static page generation when no progress happens for a while, to avoid hanging builds.

When restarted it will retry all uncompleted jobs, but if a job was unsuccessfully attempted multiple times, this will lead to an error.

#### Possible Ways to Fix It

- Make sure that there is no infinite loop during execution.
- Make sure all Promises in `getStaticProps` `resolve` or `reject` correctly.
- Avoid very long timeouts for network requests.
- Increase the timeout by changing the `experimental.staticPageGenerationTimeout` configuration option (default `60` in seconds).

### Useful Links

- [`getStaticProps`](https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation)
6 changes: 2 additions & 4 deletions examples/cms-wordpress/README.md
Expand Up @@ -60,11 +60,9 @@ Once the site is ready, you'll need to install the [WPGraphQL](https://www.wpgra

![WPGraphQL installed](./docs/plugin-installed.png)

#### Optional: Add WPGraphiQL
#### GraphiQL

The [WPGraphiQL](https://github.com/wp-graphql/wp-graphiql) plugin gives you access to a GraphQL IDE directly from your WordPress Admin, allowing you to inspect and play around with the GraphQL API.

The process to add WPGraphiQL is the same as the one for WPGraphQL: Go to the [WPGraphiQL repo](https://github.com/wp-graphql/wp-graphiql), download the ZIP archive, and install it as a plugin in your WordPress site. Once that's done you should be able to access the GraphiQL page in the admin:
The [WPGraphQL](https://www.wpgraphql.com/) plugin also gives you access to a GraphQL IDE directly from your WordPress Admin, allowing you to inspect and play around with the GraphQL API.

![WPGraphiQL page](./docs/wp-graphiql.png)

Expand Down
2 changes: 1 addition & 1 deletion examples/with-redux-wrapper/package.json
Expand Up @@ -7,7 +7,7 @@
},
"dependencies": {
"next": "9.4.1",
"next-redux-wrapper": "^6.0.1",
"next-redux-wrapper": "^7.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "7.1.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-redux-wrapper/pages/index.js
Expand Up @@ -18,7 +18,7 @@ const Index = (props) => {
return <Page title="Index Page" linkTo="/other" />
}

export const getStaticProps = wrapper.getStaticProps(async ({ store }) => {
export const getStaticProps = wrapper.getStaticProps((store) => () => {
store.dispatch(serverRenderClock(true))
store.dispatch(addCount())
})
Expand Down
10 changes: 4 additions & 6 deletions examples/with-redux-wrapper/pages/other.js
Expand Up @@ -18,12 +18,10 @@ const Other = (props) => {
return <Page title="Other Page" linkTo="/" />
}

export const getServerSideProps = wrapper.getServerSideProps(
async ({ store }) => {
store.dispatch(serverRenderClock(true))
store.dispatch(addCount())
}
)
export const getServerSideProps = wrapper.getServerSideProps((store) => () => {
store.dispatch(serverRenderClock(true))
store.dispatch(addCount())
})

const mapDispatchToProps = (dispatch) => {
return {
Expand Down
43 changes: 20 additions & 23 deletions examples/with-zustand/lib/store.js
Expand Up @@ -44,30 +44,27 @@ export const initializeStore = (preloadedState = {}) => {
}))
}

export function useHydrate(initialState) {
let _store = store ?? initializeStore(initialState)

export function useCreateStore(initialState) {
// For SSR & SSG, always use a new store.
if (typeof window !== 'undefined') {
// For CSR, always re-use same store.
if (!store) {
store = _store
}

// And if initialState changes, then merge states in the next render cycle.
//
// eslint complaining "React Hooks must be called in the exact same order in every component render"
// is ignorable as this code runs in the same order in a given environment (CSR/SSR/SSG)
// eslint-disable-next-line react-hooks/rules-of-hooks
useLayoutEffect(() => {
if (initialState && store) {
store.setState({
...store.getState(),
...initialState,
})
}
}, [initialState])
if (typeof window === 'undefined') {
return () => initializeStore(initialState)
}

return _store
// For CSR, always re-use same store.
store = store ?? initializeStore(initialState)
// And if initialState changes, then merge states in the next render cycle.
//
// eslint complaining "React Hooks must be called in the exact same order in every component render"
// is ignorable as this code runs in same order in a given environment
// eslint-disable-next-line react-hooks/rules-of-hooks
useLayoutEffect(() => {
if (initialState && store) {
store.setState({
...store.getState(),
...initialState,
})
}
}, [initialState])

return () => store
}
2 changes: 1 addition & 1 deletion examples/with-zustand/package.json
Expand Up @@ -9,7 +9,7 @@
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"zustand": "3.5.1"
"zustand": "^3.5.4"
},
"license": "MIT"
}
6 changes: 3 additions & 3 deletions examples/with-zustand/pages/_app.js
@@ -1,9 +1,9 @@
import { useHydrate, Provider } from '../lib/store'
import { useCreateStore, Provider } from '../lib/store'

export default function App({ Component, pageProps }) {
const store = useHydrate(pageProps.initialZustandState)
const createStore = useCreateStore(pageProps.initialZustandState)
return (
<Provider initialStore={store}>
<Provider createStore={createStore}>
<Component {...pageProps} />
</Provider>
)
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "11.0.2-canary.15"
"version": "11.0.2-canary.16"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"directory": "packages/eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "11.0.2-canary.15",
"@next/eslint-plugin-next": "11.0.2-canary.16",
"@rushstack/eslint-patch": "^1.0.6",
"@typescript-eslint/parser": "^4.20.0",
"eslint-import-resolver-node": "^0.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "11.0.2-canary.15",
"version": "11.0.2-canary.16",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down

0 comments on commit 23c6fdb

Please sign in to comment.