Skip to content

Commit

Permalink
Merge branch 'canary' into fix/next/build-output-formatAmpMessages-wi…
Browse files Browse the repository at this point in the history
…thout-message
  • Loading branch information
Timer authored Oct 30, 2019
2 parents c37ba81 + c4bef16 commit 1b08585
Show file tree
Hide file tree
Showing 485 changed files with 6,156 additions and 2,488 deletions.
40 changes: 39 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,27 @@ commands:
steps:
- run:
name: Installing Dependencies
command: yarn install --frozen-lockfile
command: yarn install --frozen-lockfile --check-files
- run:
name: Install correct Chrome Driver version
command: yarn add chromedriver@76 -W && git checkout yarn.lock package.json
- run: google-chrome --version
- run: chromedriver --version
yarn_lint:
steps:
- run:
name: Linting
command: yarn lint
yarn_react_integration:
steps:
- run:
name: Upgrade to most recent release in React's Next channel
command: yarn upgrade react@next react-dom@next -W --dev # upgrade (vs add) will skip re-building Next.js, which doesn't bundle React internals (so this is OK!)
yarn_info:
steps:
- run:
name: React Versions
command: yarn why react && yarn why react-dom
test_all:
steps:
- run:
Expand Down Expand Up @@ -114,11 +129,18 @@ jobs:
- yarn_install
- yarn_lint
- *persist_to_workspace
build-react-canary:
executor: node
steps:
- *attach_workspace
- yarn_react_integration
- *persist_to_workspace
test:
parallelism: 3
executor: node
steps:
- *attach_workspace
- yarn_info
- test_all
- *store_test_results
test-ie11:
Expand Down Expand Up @@ -196,3 +218,19 @@ workflows:
only:
- master
- canary
q12h-react-canary:
triggers:
- schedule:
cron: '0 0,12 * * *'
filters:
branches:
only:
- canary
jobs:
- build
- build-react-canary:
requires:
- build
- test:
requires:
- build-react-canary
8 changes: 4 additions & 4 deletions README-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default () => <div>Welcome to next.js!</div>
- 自动打包编译 (使用 webpack 和 babel)
- 热加载
-`./pages`作为服务的渲染和索引
- 静态文件服务. `./static/` 映射到 `/static/` (可以 [创建一个静态目录](#static-file-serving-eg-images) 在你的项目中)
- 静态文件服务. `./public/` 映射到 `/` (可以 [创建一个静态目录](#static-file-serving-eg-images) 在你的项目中)

这里有个简单的案例,可以下载看看 [sample app - nextgram](https://github.com/zeit/nextgram)

Expand Down Expand Up @@ -227,13 +227,13 @@ export default () => <p style={{ color: 'red' }}>hi there</p>

### 静态文件服务(如图像)

在根目录下新建文件夹叫`static`。代码可以通过`/static/`来引入相关的静态资源。
在根目录下新建文件夹叫`public`。代码可以通过`/`来引入相关的静态资源。

```jsx
export default () => <img src="/static/my-image.png" alt="my image" />
export default () => <img src="/my-image.png" alt="my image" />
```

_注意:不要自定义静态文件夹的名字,只能叫`static` ,因为只有这个名字 Next.js 才会把它当作静态资源。_
_注意:不要自定义静态文件夹的名字,只能叫`public` ,因为只有这个名字 Next.js 才会把它当作静态资源。_

<a id="populating-head" style="display: none"></a>

Expand Down
7 changes: 6 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pool:
variables:
NEXT_TELEMETRY_DISABLED: '1'
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn
CHROMEDRIVER_VERSION: '76.0.3809.68'

strategy:
maxParallel: 10
Expand Down Expand Up @@ -34,9 +35,13 @@ steps:
displayName: Cache Yarn packages

- script: |
yarn --frozen-lockfile --check-files
yarn install --frozen-lockfile --check-files
displayName: 'Install dependencies'
- script: |
yarn add chromedriver@76 -W
displayName: 'Install correct Chrome Driver version'
- script: |
node run-tests.js -c 2 -g $(group)
displayName: 'Run tests'
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Our Commitment to Open Source can be found [here](https://zeit.co/blog/oss)
3. Install the dependencies: `yarn`
4. Run `yarn dev` to build and watch for code changes
5. In a new terminal, run `yarn types` to compile declaration files from TypeScript
6. The development branch is `canary`. On a release, the relevant parts of the changes in the `canary` branch are rebased into `master`.
6. The development branch is `canary` (this is the branch pull requests should be made against). On a release, the relevant parts of the changes in the `canary` branch are rebased into `master`.

> You may need to run `yarn types` again if your types get outdated.
Expand Down
15 changes: 15 additions & 0 deletions errors/can-not-output-to-public.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Cannot output to /public

#### Why This Error Occurred

Either you set `distDir` to `public` in your `next.config.js` or during `next export` you tried to export to the `public` directory.

This is not allowed due to `public` being a special folder in Next.js used to serve static assets.

#### Possible Ways to Fix It

Use a different `distDir` or export to a different folder.

### Useful Links

- [Static file serving docs](https://nextjs.org/docs#static-file-serving-eg-images)
4 changes: 2 additions & 2 deletions errors/empty-object-getInitialProps.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#### Why This Error Occurred

In one of your page components you added a `getInitialProps` that returned an empty object. This de-optimizes automatic prerendering. If you **meant** to do this and understand the **consequences** you can ignore this message as it is only shown in development.
In one of your page components you added a `getInitialProps` that returned an empty object. This de-optimizes automatic static optimization. If you **meant** to do this and understand the **consequences** you can ignore this message as it is only shown in development.

#### Possible Ways to Fix It

Look for any page's using `getInitialProps` that return an empty object `{}`. You might also need to update higher order components (HOCs) to only add `getInitialProps` if they are present on the passed component.

### Useful Links

- [Automatic Prerendering Documentation](https://nextjs.org/docs/#automatic-prerendering)
- [Automatic Static Optimization Documentation](https://nextjs.org/docs/#automatic-static-optimization)
11 changes: 11 additions & 0 deletions errors/global-css.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Global CSS Must Be in Your Custom <App>

#### Why This Error Occurred

An attempt to import Global CSS from a file other than `pages/_app.js` was made.

Global CSS cannot be used in files other than your Custom `<App>` due to its side-effects and ordering problems.

#### Possible Ways to Fix It

Relocate all Global CSS imports to your `pages/_app.js` file.
76 changes: 76 additions & 0 deletions errors/no-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# No Cache Detected

#### Why This Error Occurred

A Next.js build was triggered in a continuous integration environment, but no cache was detected.

This results in slower builds and can hurt Next.js' persistent caching of client-side bundles across builds.

#### Possible Ways to Fix It

> **Note**: If this is a new project, or being built for the first time in your CI, you can ignore this error.
> However, you'll want to make sure it doesn't continue to happen and fix it if it does!
Configure Next.js' cache to be persisted across builds. Next.js stores its cache in the `.next/cache` directory.

Storing this folder across builds varies by CI provider. We've provided a list of a few common providers below.

**ZEIT Now**

Next.js caching is automatically configured for you. There's no action required on your part.

**CircleCI**

Edit your `save_cache` step in `.circleci/config.yml` to include `.next/cache`:

```yaml
steps:
- save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
- ./.next/cache
```
If you do not have a `save_cache` key, please follow CircleCI's [documentation on setting up build caching](https://circleci.com/docs/2.0/caching/).

**Travis CI**

Add or merge the following into your `.travis.yml`:

```yaml
cache:
directories:
- $HOME/.cache/yarn
- node_modules
- .next/cache
```

**GitLab CI**

Add or merge the following into your `.gitlab-ci.yml`:

```yaml
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .next/cache/
```

**Netlify CI**

It is **not possible** to cache custom build files on Netlify. Please contact their support and request they support this behavior.

You can investigate using a 3rd party solution (e.g. [`cache-me-outside`](https://github.com/DavidWells/cache-me-outside)) to manually cache the Next.js output.

**AWS CodeBuild**

Add (or merge in) the following to your `buildspec.yml`:

```yaml
cache:
paths:
- 'node_modules/**/*' # Cache `node_modules` for faster `yarn` or `npm i`
- '.next/cache/**/*' # Cache Next.js for faster application rebuilds
```
6 changes: 3 additions & 3 deletions errors/no-document-title.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Set `<title>` in `pages/_app.js` instead:

```js
// pages/_app.js
import App, { Container } from 'next/app'
import App from 'next/app'
import Head from 'next/head'
import React from 'react'

Expand All @@ -29,12 +29,12 @@ export default class MyApp extends App {
const { Component, pageProps } = this.props

return (
<Container>
<>
<Head>
<title>My new cool app</title>
</Head>
<Component {...pageProps} />
</Container>
</>
)
}
}
Expand Down
35 changes: 35 additions & 0 deletions errors/opt-out-auto-static-optimization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Opt-out of Automatic Static Optimization

#### Why This Warning Occurred

You are using `getInitialProps` in your [Custom `<App>`](https://nextjs.org/docs#custom-app).

This causes **all pages** to be executed on the server -- disabling [Automatic Static Optimization](https://nextjs.org/docs#automatic-static-optimization).

#### Possible Ways to Fix It

Be sure you meant to use `getInitialProps` in `pages/_app`!
There are some valid use cases for this, but it is often better to handle `getInitialProps` on a _per-page_ basis.

If you previously copied the [Custom `<App>`](https://nextjs.org/docs#custom-app) example, you may be able to remove your `getInitialProps`.

The following `getInitialProps` does nothing and may be removed:

```js
class MyApp extends App {
// Remove me, I do nothing!
static async getInitialProps({ Component, ctx }) {
let pageProps = {}

if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}

return { pageProps }
}

render() {
// ...
}
}
```
4 changes: 2 additions & 2 deletions errors/opt-out-automatic-prerendering.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Opt-out of Automatic Prerendering
# Opt-out of Automatic Static Optimization

#### Why This Warning Occurred

You are using `getInitialProps` in your [Custom `<App>`](https://nextjs.org/docs#custom-app).

This causes **all pages** to be executed on the server -- disabling [Automatic Prerendering](https://nextjs.org/docs#automatic-prerendering).
This causes **all pages** to be executed on the server -- disabling [Automatic Static Optimization](https://nextjs.org/docs#automatic-static-optimization).

#### Possible Ways to Fix It

Expand Down
11 changes: 9 additions & 2 deletions errors/page-without-valid-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

#### Why This Error Occurred

While auto exporting a page a valid React Component wasn't found. This could mean you have a file in `pages` that exports something that is not a React Component.
A page that does not export a valid React Component was found while analyzing the build output.

This is a hard error because the page would error when rendered, and causes poor build performance.

#### Possible Ways to Fix It

Move any non-page files that don't export a React Component as the default export to a different folder like `components` or `lib`.
Investigate the list of page(s) specified in the error message.
For each, you'll want to check if the file is meant to be a page.

If the file is not meant to be a page, and instead, is a shared component or file, move the file to a different folder like `components` or `lib`.

If the file is meant to be a page, double check you have an `export default` with the React Component instead of an `export`. If you're already using `export default`, make sure the returned valid is a valid React Component.
4 changes: 2 additions & 2 deletions errors/serverless-publicRuntimeConfig.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Using `publicRuntimeConfig` with `target` set to `serverless`
# Using `publicRuntimeConfig` or `serverRuntimeConfig` with `target` set to `serverless`

#### Why This Error Occurred

In the `serverless` target environment `next.config.js` is not loaded, so we don't support `publicRuntimeConfig`.
In the `serverless` target environment `next.config.js` is not loaded, so we don't support `publicRuntimeConfig` or `serverRuntimeConfig`.

#### Possible Ways to Fix It

Expand Down
38 changes: 38 additions & 0 deletions errors/static-dir-deprecated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Static directory is deprecated

#### Why This Error Occurred

In versions prior to 9.0.6 the `static` directory was used to serve static assets in a Next.js application. This has been deprecated in favor of a `public` directory.

The reason we want to support a `public` directory instead is to not require the `/static` prefix for assets anymore and there is no reason to maintain both paths.

#### Possible Ways to Fix It

You can move your `static` directory inside of the `public` directory and all URLs will remain the same as they were before.

**Before**

```sh
static/
my-image.jpg
pages/
index.js
components/
my-image.js
```

**After**

```sh
public/
static/
my-image.jpg
pages/
index.js
components/
my-image.js
```

### Useful Links

- [Static file serving docs](https://nextjs.org/docs#static-file-serving-eg-images)
2 changes: 1 addition & 1 deletion examples/active-class-name/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Using `create-next-app`

Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example active-class-name active-class-name-app
Expand Down
3 changes: 3 additions & 0 deletions examples/amp-story/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
.next
node_modules
Loading

0 comments on commit 1b08585

Please sign in to comment.