Skip to content

Commit

Permalink
Merge branch 'canary' into rename-zeitco-new-import
Browse files Browse the repository at this point in the history
  • Loading branch information
chibicode committed Feb 24, 2020
2 parents c1049e1 + 03611ee commit 958326b
Show file tree
Hide file tree
Showing 30 changed files with 628 additions and 229 deletions.
2 changes: 1 addition & 1 deletion errors/invalid-getstaticpaths-value.md
Expand Up @@ -9,7 +9,7 @@ In one of the page's `unstable_getStaticPaths` the return value had the incorrec
Make sure to return the following shape from `unstable_getStaticPaths`:

```js
export async function unstable_getStaticProps() {
export async function unstable_getStaticPaths() {
return {
paths: Array<string | { params: { [key: string]: string } }>
}
Expand Down
42 changes: 42 additions & 0 deletions errors/routes-must-be-array.md
@@ -0,0 +1,42 @@
# Custom Routes must return an array

#### Why This Error Occurred

When defining custom routes an array wasn't returned from either `headers`, `rewrites`, or `redirects`.

#### Possible Ways to Fix It

Make sure to return an array that contains the routes.

**Before**

```js
// next.config.js
module.exports = {
experimental: {
async rewrites() {
return {
source: '/feedback',
destination: '/feedback/general',
}
},
},
}
```

**After**

```js
module.exports = {
experimental: {
async rewrites() {
return [
{
source: '/feedback',
destination: '/feedback/general',
},
]
},
},
}
```
4 changes: 1 addition & 3 deletions examples/with-mobx-keystone-typescript/components/Clock.tsx
Expand Up @@ -16,9 +16,7 @@ const Clock: FC<Props> = props => {
font: '50px menlo, monaco, monospace',
padding: '15px',
}
return (
<div style={divStyle}>{format(new Date(props.lastUpdate as number))}</div>
)
return <div style={divStyle}>{format(props.lastUpdate)}</div>
}

export { Clock }
2 changes: 1 addition & 1 deletion examples/with-mobx-keystone-typescript/package.json
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"mobx": "^5.15.1",
"mobx-keystone": "^0.30.0",
"mobx-keystone": "^0.41.0",
"mobx-react-lite": "^1.5.2",
"next": "latest",
"react": "^16.12.0",
Expand Down
15 changes: 9 additions & 6 deletions examples/with-mobx-keystone-typescript/store/root.ts
@@ -1,16 +1,19 @@
import { Model, model, prop, modelAction, timestampAsDate } from 'mobx-keystone'
import {
Model,
model,
prop,
modelAction,
prop_dateTimestamp,
} from 'mobx-keystone'

@model('store/root')
class RootStore extends Model({
foo: prop<number | null>(0),
lastUpdate: prop<number | null>(new Date().getTime()),
lastUpdate: prop_dateTimestamp(() => new Date()),
light: prop(false),
}) {
timer!: ReturnType<typeof setInterval>

@timestampAsDate('lastUpdate')
lastUpdateDate!: Date

@modelAction
start() {
this.timer = setInterval(() => {
Expand All @@ -19,7 +22,7 @@ class RootStore extends Model({
}
@modelAction
update() {
this.lastUpdate = Date.now()
this.lastUpdate = new Date()
this.light = true
}

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -12,5 +12,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "9.2.3-canary.10"
"version": "9.2.3-canary.12"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "9.2.3-canary.10",
"version": "9.2.3-canary.12",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "9.2.3-canary.10",
"version": "9.2.3-canary.12",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "9.2.3-canary.10",
"version": "9.2.3-canary.12",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-google-analytics/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-google-analytics",
"version": "9.2.3-canary.10",
"version": "9.2.3-canary.12",
"nextjs": {
"name": "Google Analytics",
"required-env": [
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-material-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-material-ui",
"version": "9.2.3-canary.10",
"version": "9.2.3-canary.12",
"nextjs": {
"name": "Material UI",
"required-env": []
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-sentry/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "9.2.3-canary.10",
"version": "9.2.3-canary.12",
"nextjs": {
"name": "Sentry",
"required-env": [
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "9.2.3-canary.10",
"version": "9.2.3-canary.12",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
17 changes: 10 additions & 7 deletions packages/next/build/index.ts
Expand Up @@ -113,21 +113,24 @@ export default async function build(dir: string, conf = null): Promise<void> {
const { target } = config
const buildId = await generateBuildId(config.generateBuildId, nanoid)
const distDir = path.join(dir, config.distDir)
const headers: Header[] = []
const rewrites: Rewrite[] = []
const redirects: Redirect[] = []
const headers: Header[] = []

if (typeof config.experimental.redirects === 'function') {
redirects.push(...(await config.experimental.redirects()))
checkCustomRoutes(redirects, 'redirect')
const _redirects = await config.experimental.redirects()
checkCustomRoutes(_redirects, 'redirect')
redirects.push(..._redirects)
}
if (typeof config.experimental.rewrites === 'function') {
rewrites.push(...(await config.experimental.rewrites()))
checkCustomRoutes(rewrites, 'rewrite')
const _rewrites = await config.experimental.rewrites()
checkCustomRoutes(_rewrites, 'rewrite')
rewrites.push(..._rewrites)
}
if (typeof config.experimental.headers === 'function') {
headers.push(...(await config.experimental.headers()))
checkCustomRoutes(headers, 'header')
const _headers = await config.experimental.headers()
checkCustomRoutes(_headers, 'header')
headers.push(..._headers)
}

if (ciEnvironment.isCI) {
Expand Down

0 comments on commit 958326b

Please sign in to comment.