Skip to content

Commit

Permalink
Merge branch 'canary' into cli-create-from-example
Browse files Browse the repository at this point in the history
  • Loading branch information
merelinguist authored Feb 17, 2020
2 parents 1e54816 + 9cfc09e commit 5952dfa
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 188 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "9.2.2-canary.20"
"version": "9.2.2-canary.21"
}
5 changes: 5 additions & 0 deletions packages/create-next-app/create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export async function createApp({
case 'gitignore': {
return '.'.concat(name)
}
// README.md is ignored by webpack-asset-relocator-loader used by ncc:
// https://github.com/zeit/webpack-asset-relocator-loader/blob/e9308683d47ff507253e37c9bcbb99474603192b/src/asset-relocator.js#L227
case 'README-template.md': {
return 'README.md'
}
default: {
return name
}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "9.2.2-canary.20",
"version": "9.2.2-canary.21",
"keywords": [
"react",
"next",
Expand Down
30 changes: 30 additions & 0 deletions packages/create-next-app/templates/default/README-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/zeit/next.js/) - your feedback and contributions are welcome!

## Deploy on ZEIT Now

The easiest way to deploy your Next.js app is to use the [ZEIT Now Platform](https://zeit.co/) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
171 changes: 0 additions & 171 deletions packages/create-next-app/templates/default/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "9.2.2-canary.20",
"version": "9.2.2-canary.21",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "9.2.2-canary.20",
"version": "9.2.2-canary.21",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-google-analytics",
"version": "9.2.2-canary.20",
"version": "9.2.2-canary.21",
"nextjs": {
"name": "Google Analytics",
"required-env": [
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-material-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-material-ui",
"version": "9.2.2-canary.20",
"version": "9.2.2-canary.21",
"nextjs": {
"name": "Material UI",
"required-env": []
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-sentry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "9.2.2-canary.20",
"version": "9.2.2-canary.21",
"nextjs": {
"name": "Sentry",
"required-env": [
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "9.2.2-canary.20",
"version": "9.2.2-canary.21",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions packages/next/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export default async ({ webpackHMR: passedWebpackHMR } = {}) => {
Component,
wrapApp,
err: initialErr,
isFallback,
subscription: ({ Component, props, err }, App) => {
render({ App, Component, props, err })
},
Expand Down
9 changes: 8 additions & 1 deletion packages/next/client/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ const singletonRouter: SingletonRouterBase = {
}

// Create public properties and methods of the router in the singletonRouter
const urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components']
const urlPropertyFields = [
'pathname',
'route',
'query',
'asPath',
'components',
'isFallback',
]
const routerEvents = [
'routeChangeStart',
'beforeHistoryChange',
Expand Down
8 changes: 8 additions & 0 deletions packages/next/next-server/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type NextRouter = BaseRouter &
| 'prefetch'
| 'beforePopState'
| 'events'
| 'isFallback'
>

type RouteInfo = {
Expand Down Expand Up @@ -122,6 +123,7 @@ export default class Router implements BaseRouter {
events: MittEmitter
_wrapApp: (App: ComponentType) => any
isSsr: boolean
isFallback: boolean

static events: MittEmitter = mitt()

Expand All @@ -137,6 +139,7 @@ export default class Router implements BaseRouter {
Component,
err,
subscription,
isFallback,
}: {
subscription: Subscription
initialProps: any
Expand All @@ -145,6 +148,7 @@ export default class Router implements BaseRouter {
App: ComponentType
wrapApp: (App: ComponentType) => any
err?: Error
isFallback: boolean
}
) {
// represents the current component key
Expand Down Expand Up @@ -180,6 +184,8 @@ export default class Router implements BaseRouter {
// back from external site
this.isSsr = true

this.isFallback = isFallback

if (typeof window !== 'undefined') {
// in order for `e.state` to work on the `onpopstate` event
// we have to register the initial route upon initialization
Expand Down Expand Up @@ -580,6 +586,8 @@ export default class Router implements BaseRouter {
as: string,
data: RouteInfo
): void {
this.isFallback = false

this.route = route
this.pathname = pathname
this.query = query
Expand Down
14 changes: 12 additions & 2 deletions packages/next/next-server/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,22 @@ class ServerRouter implements NextRouter {
query: ParsedUrlQuery
asPath: string
events: any
isFallback: boolean
// TODO: Remove in the next major version, as this would mean the user is adding event listeners in server-side `render` method
static events: MittEmitter = mitt()

constructor(pathname: string, query: ParsedUrlQuery, as: string) {
constructor(
pathname: string,
query: ParsedUrlQuery,
as: string,
{ isFallback }: { isFallback: boolean }
) {
this.route = pathname.replace(/\/$/, '') || '/'
this.pathname = pathname
this.query = query
this.asPath = as

this.isFallback = isFallback
}
push(): any {
noRouter()
Expand Down Expand Up @@ -394,7 +402,9 @@ export async function renderToHTML(

// @ts-ignore url will always be set
const asPath: string = req.url
const router = new ServerRouter(pathname, query, asPath)
const router = new ServerRouter(pathname, query, asPath, {
isFallback: isFallback,
})
const ctx = {
err,
req: isAutoExport ? undefined : req,
Expand Down
Loading

0 comments on commit 5952dfa

Please sign in to comment.