Skip to content

Commit

Permalink
Merge branch 'canary' into fix-storybook-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jan 26, 2021
2 parents bcb70fd + 0370c03 commit 0ba5c15
Show file tree
Hide file tree
Showing 26 changed files with 185 additions and 67 deletions.
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Description

## Deploy your own

Deploy the example using [Vercel](https://vercel.com/now):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/DIRECTORY_NAME&project-name=DIRECTORY_NAME&repository-name=DIRECTORY_NAME)

Expand Down
1 change: 1 addition & 0 deletions docs/advanced-features/preview-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ description: Next.js has the preview mode for statically generated pages. You ca
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-buttercms">ButterCMS Example</a> (<a href="https://next-blog-buttercms.now.sh/">Demo</a>)</li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-storyblok">Storyblok Example</a> (<a href="https://next-blog-storyblok.now.sh/">Demo</a>)</li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-graphcms">GraphCMS Example</a> (<a href="https://next-blog-graphcms.now.sh/">Demo</a>)</li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/cms-kontent">Kontent Example</a> (<a href="https://next-blog-kontent.vercel.app//">Demo</a>)</li>
</ul>
</details>

Expand Down
2 changes: 1 addition & 1 deletion examples/with-goober/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Goober initially started with a slogan as "a less than 1KB css-in-js library at

## Deploy your own

Deploy the example using [Vercel](https://vercel.com/now):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-goober&project-name=with-goober&repository-name=with-goober)

Expand Down
2 changes: 1 addition & 1 deletion examples/with-hls-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This example shows how to use Next.js along with [HLS.js](https://github.com/vid

## Deploy your own

Deploy the example using [Vercel](https://vercel.com/now):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-hls-js&project-name=with-hls-js&repository-name=with-hls-js)

Expand Down
2 changes: 1 addition & 1 deletion examples/with-react-md-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ for a more complex example of using ReactMD + Next.js.

## Deploy your own

Deploy the example using [Vercel](https://vercel.com/now):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-react-md-typescript&project-name=with-react-md-typescript&repository-name=with-react-md-typescript)

Expand Down
2 changes: 1 addition & 1 deletion examples/with-react-md/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ example for Typescript support.

## Deploy your own

Deploy the example using [Vercel](https://vercel.com/now):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-react-md&project-name=with-react-md&repository-name=with-react-md)

Expand Down
2 changes: 1 addition & 1 deletion examples/with-service-worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The example is based on the following blog post: [Adding a service worker into y

## Deploy your own

Deploy the example using [Vercel](https://vercel.com/now):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-service-worker&project-name=with-service-worker&repository-name=with-service-worker)

Expand Down
5 changes: 5 additions & 0 deletions examples/with-typescript-eslint-jest/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"jest": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"react/react-in-jsx-scope": 0,
"react/display-name": 0,
Expand Down
2 changes: 1 addition & 1 deletion examples/with-urql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Use [urql](https://github.com/FormidableLabs/urql) with Next.js using SSG.

## Deploy your own

Deploy the example using [Vercel](https://vercel.com/now):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-urql&project-name=with-urql&repository-name=with-urql)

Expand Down
2 changes: 1 addition & 1 deletion packages/next/compiled/cacache/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/compiled/cache-loader/cjs.js

Large diffs are not rendered by default.

21 changes: 0 additions & 21 deletions packages/next/compiled/mkdirp/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/compiled/mkdirp/index.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/compiled/mkdirp/package.json

This file was deleted.

118 changes: 108 additions & 10 deletions packages/next/compiled/webpack/bundle4.js
Original file line number Diff line number Diff line change
Expand Up @@ -36452,6 +36452,112 @@ module.exports = function isExtendable(val) {
};


/***/ }),

/***/ 50998:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

var path = __webpack_require__(85622);
var fs = __webpack_require__(35747);
var _0777 = parseInt('0777', 8);

module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;

function mkdirP (p, opts, f, made) {
if (typeof opts === 'function') {
f = opts;
opts = {};
}
else if (!opts || typeof opts !== 'object') {
opts = { mode: opts };
}

var mode = opts.mode;
var xfs = opts.fs || fs;

if (mode === undefined) {
mode = _0777
}
if (!made) made = null;

var cb = f || function () {};
p = path.resolve(p);

xfs.mkdir(p, mode, function (er) {
if (!er) {
made = made || p;
return cb(null, made);
}
switch (er.code) {
case 'ENOENT':
if (path.dirname(p) === p) return cb(er);
mkdirP(path.dirname(p), opts, function (er, made) {
if (er) cb(er, made);
else mkdirP(p, opts, cb, made);
});
break;

// In the case of any other error, just see if there's a dir
// there already. If so, then hooray! If not, then something
// is borked.
default:
xfs.stat(p, function (er2, stat) {
// if the stat fails, then that's super weird.
// let the original error be the failure reason.
if (er2 || !stat.isDirectory()) cb(er, made)
else cb(null, made);
});
break;
}
});
}

mkdirP.sync = function sync (p, opts, made) {
if (!opts || typeof opts !== 'object') {
opts = { mode: opts };
}

var mode = opts.mode;
var xfs = opts.fs || fs;

if (mode === undefined) {
mode = _0777
}
if (!made) made = null;

p = path.resolve(p);

try {
xfs.mkdirSync(p, mode);
made = made || p;
}
catch (err0) {
switch (err0.code) {
case 'ENOENT' :
made = sync(path.dirname(p), opts, made);
sync(p, opts, made);
break;

// In the case of any other error, just see if there's a dir
// there already. If so, then hooray! If not, then something
// is borked.
default:
var stat;
try {
stat = xfs.statSync(p);
}
catch (err1) {
throw err0;
}
if (!stat.isDirectory()) throw err0;
break;
}
}

return made;
};


/***/ }),

/***/ 57925:
Expand Down Expand Up @@ -78593,7 +78699,7 @@ module.exports = (a, b) => {

const fs = __webpack_require__(35747);
const path = __webpack_require__(85622);
const mkdirp = __webpack_require__(94327);
const mkdirp = __webpack_require__(50998);
const { Tracer } = __webpack_require__(92430);
const validateOptions = __webpack_require__(33225);
const schema = __webpack_require__(49049);
Expand Down Expand Up @@ -86946,7 +87052,7 @@ module.exports = class NodeMainTemplatePlugin {

const fs = __webpack_require__(35747);
const path = __webpack_require__(85622);
const mkdirp = __webpack_require__(94327);
const mkdirp = __webpack_require__(50998);

class NodeOutputFileSystem {
constructor() {
Expand Down Expand Up @@ -105954,14 +106060,6 @@ module.exports = require("next/dist/compiled/is-wsl");;

/***/ }),

/***/ 94327:
/***/ (function(module) {

"use strict";
module.exports = require("next/dist/compiled/mkdirp");;

/***/ }),

/***/ 36386:
/***/ (function(module) {

Expand Down
13 changes: 8 additions & 5 deletions packages/next/next-server/lib/post-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async function processHTML(
}

class FontOptimizerMiddleware implements PostProcessMiddleware {
fontDefinitions: Array<string> = []
fontDefinitions: (string | undefined)[][] = []
inspect(
originalDom: HTMLElement,
_data: postProcessData,
Expand All @@ -112,8 +112,10 @@ class FontOptimizerMiddleware implements PostProcessMiddleware {
)
.forEach((element: HTMLElement) => {
const url = element.getAttribute('data-href')
const nonce = element.getAttribute('nonce')

if (url) {
this.fontDefinitions.push(url)
this.fontDefinitions.push([url, nonce])
}
})
}
Expand All @@ -127,7 +129,7 @@ class FontOptimizerMiddleware implements PostProcessMiddleware {
return markup
}
for (const key in this.fontDefinitions) {
const url = this.fontDefinitions[key]
const [url, nonce] = this.fontDefinitions[key]
const fallBackLinkTag = `<link rel="stylesheet" href="${url}"/>`
if (
result.indexOf(`<style data-href="${url}">`) > -1 ||
Expand All @@ -136,16 +138,17 @@ class FontOptimizerMiddleware implements PostProcessMiddleware {
// The font is already optimized and probably the response is cached
continue
}
const fontContent = options.getFontDefinition(url)
const fontContent = options.getFontDefinition(url as string)
if (!fontContent) {
/**
* In case of unreachable font definitions, fallback to default link tag.
*/
result = result.replace('</head>', `${fallBackLinkTag}</head>`)
} else {
const nonceStr = nonce ? ` nonce="${nonce}"` : ''
result = result.replace(
'</head>',
`<style data-href="${url}">${fontContent}</style></head>`
`<style data-href="${url}"${nonceStr}>${fontContent}</style></head>`
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/next-server/server/api-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export function sendData(
res: NextApiResponse,
body: any
): void {
if (body === null) {
if (body === null || body === undefined) {
res.end()
return
}
Expand Down
10 changes: 8 additions & 2 deletions packages/next/next-server/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ import {
NextComponentType,
RenderPage,
} from '../lib/utils'
import { tryGetPreviewData, __ApiPreviewProps } from './api-utils'
import {
tryGetPreviewData,
NextApiRequestCookies,
__ApiPreviewProps,
} from './api-utils'
import { denormalizePagePath } from './denormalize-page-path'
import { FontManifest, getFontDefinitionFromManifest } from './font-utils'
import { LoadComponentsReturnType, ManifestItem } from './load-components'
Expand Down Expand Up @@ -796,7 +800,9 @@ export async function renderToHTML(

try {
data = await getServerSideProps({
req,
req: req as IncomingMessage & {
cookies: NextApiRequestCookies
},
res,
query,
resolvedUrl: renderOpts.resolvedUrl as string,
Expand Down
1 change: 0 additions & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@
"loader-utils": "2.0.0",
"lodash.curry": "4.1.1",
"lru-cache": "5.1.1",
"mkdirp": "0.5.3",
"nanoid": "3.1.20",
"neo-async": "2.6.1",
"ora": "4.0.4",
Expand Down
9 changes: 0 additions & 9 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,6 @@ export async function ncc_lru_cache(task, opts) {
.target('compiled/lru-cache')
}
// eslint-disable-next-line camelcase
externals['mkdirp'] = 'next/dist/compiled/mkdirp'
export async function ncc_mkdirp(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('mkdirp')))
.ncc({ packageName: 'mkdirp', externals })
.target('compiled/mkdirp')
}
// eslint-disable-next-line camelcase
externals['nanoid'] = 'next/dist/compiled/nanoid'
export async function ncc_nanoid(task, opts) {
await task
Expand Down Expand Up @@ -707,7 +699,6 @@ export async function ncc(task) {
'ncc_loader_utils',
'ncc_lodash_curry',
'ncc_lru_cache',
'ncc_mkdirp',
'ncc_nanoid',
'ncc_neo_async',
'ncc_ora',
Expand Down
7 changes: 6 additions & 1 deletion packages/next/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import {
// @ts-ignore This path is generated at build time and conflicts otherwise
} from '../dist/next-server/lib/utils'

import {
NextApiRequestCookies,
// @ts-ignore This path is generated at build time and conflicts otherwise
} from '../dist/next-server/server/api-utils'

// @ts-ignore This path is generated at build time and conflicts otherwise
import next from '../dist/server/next'

Expand Down Expand Up @@ -130,7 +135,7 @@ export type GetServerSidePropsContext<
Q extends ParsedUrlQuery = ParsedUrlQuery
> = {
req: IncomingMessage & {
cookies?: { [key: string]: any }
cookies: NextApiRequestCookies
}
res: ServerResponse
params?: Q
Expand Down
3 changes: 3 additions & 0 deletions test/integration/api-support/pages/api/undefined.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default (req, res) => {
res.json(undefined)
}
Loading

0 comments on commit 0ba5c15

Please sign in to comment.