Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/canary' into docs/i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 22, 2020
2 parents 43d53f5 + fe4d16c commit 5fd6a11
Show file tree
Hide file tree
Showing 66 changed files with 1,024 additions and 303 deletions.
17 changes: 15 additions & 2 deletions errors/install-sharp.md
Expand Up @@ -2,14 +2,27 @@

#### Why This Error Occurred

Using Next.js' built-in Image Optimization requires that you bring your own version of `sharp`.
Using Next.js' built-in Image Optimization requires that you install `sharp`.

Since `sharp` is optional, it may have been skipped if you installed `next` with the [`--no-optional`](https://docs.npmjs.com/cli/install) flag or it may have been skipped if your platform does not support `sharp`.

#### Possible Ways to Fix It

Please install the `sharp` package in your project.
Option 1: Install the `sharp` package in your project.

```bash
npm i sharp
# or
yarn add sharp
```

Option 2: Configure an external loader in `next.config.js` such as [imgix](https://imgix.com).

```js
module.exports = {
images: {
path: 'https://example.com/myaccount/',
loader: 'imgix',
},
}
```
@@ -1,8 +1,8 @@
export const mapUserData = (user) => {
const { uid, email, xa } = user
const { uid, email, xa, ya } = user
return {
id: uid,
email,
token: xa,
token: xa || ya,
}
}
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "9.5.6-canary.9"
"version": "9.5.6-canary.12"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "9.5.6-canary.9",
"version": "9.5.6-canary.12",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "9.5.6-canary.9",
"version": "9.5.6-canary.12",
"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": "9.5.6-canary.9",
"version": "9.5.6-canary.12",
"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": "9.5.6-canary.9",
"version": "9.5.6-canary.12",
"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": "9.5.6-canary.9",
"version": "9.5.6-canary.12",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "9.5.6-canary.9",
"version": "9.5.6-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.5.6-canary.9",
"version": "9.5.6-canary.12",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-google-analytics"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-sentry/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "9.5.6-canary.9",
"version": "9.5.6-canary.12",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-sentry"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "9.5.6-canary.9",
"version": "9.5.6-canary.12",
"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": "9.5.6-canary.9",
"version": "9.5.6-canary.12",
"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": "9.5.6-canary.9",
"version": "9.5.6-canary.12",
"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/build/entries.ts
Expand Up @@ -79,6 +79,7 @@ export function createEntrypoints(
absoluteAppPath: pages['/_app'],
absoluteDocumentPath: pages['/_document'],
absoluteErrorPath: pages['/_error'],
absolute404Path: pages['/404'] || '',
distDir: DOT_NEXT_ALIAS,
buildId,
assetPrefix: config.assetPrefix,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/utils.ts
Expand Up @@ -544,7 +544,7 @@ export async function buildStaticPaths(
// Get the default list of allowed params.
const _validParamKeys = Object.keys(_routeMatcher(page))

const staticPathsResult = await getStaticPaths()
const staticPathsResult = await getStaticPaths({ locales })

const expectedReturnVal =
`Expected: { paths: [], fallback: boolean }\n` +
Expand Down
1 change: 0 additions & 1 deletion packages/next/build/webpack-config.ts
Expand Up @@ -994,7 +994,6 @@ export default async function getBaseWebpackConfig(
sizes: config.images.sizes,
path: config.images.path,
loader: config.images.loader,
autoOptimize: config.images.autoOptimize,
}),
'process.env.__NEXT_ROUTER_BASEPATH': JSON.stringify(config.basePath),
'process.env.__NEXT_HAS_REWRITES': JSON.stringify(hasRewrites),
Expand Down
@@ -1,12 +1,12 @@
import postcss from 'postcss'
import { AcceptedPlugin } from 'postcss'
import webpack from 'webpack'
import { ConfigurationContext } from '../../../utils'
import { getClientStyleLoader } from './client'
import { cssFileResolve } from './file-resolve'

export function getGlobalCssLoader(
ctx: ConfigurationContext,
postCssPlugins: readonly postcss.AcceptedPlugin[],
postCssPlugins: readonly AcceptedPlugin[],
preProcessors: readonly webpack.RuleSetUseItem[] = []
): webpack.RuleSetUseItem[] {
const loaders: webpack.RuleSetUseItem[] = []
Expand Down
@@ -1,4 +1,4 @@
import postcss from 'postcss'
import { AcceptedPlugin } from 'postcss'
import webpack from 'webpack'
import { ConfigurationContext } from '../../../utils'
import { getClientStyleLoader } from './client'
Expand All @@ -7,7 +7,7 @@ import { getCssModuleLocalIdent } from './getCssModuleLocalIdent'

export function getCssModuleLoader(
ctx: ConfigurationContext,
postCssPlugins: readonly postcss.AcceptedPlugin[],
postCssPlugins: readonly AcceptedPlugin[],
preProcessors: readonly webpack.RuleSetUseItem[] = []
): webpack.RuleSetUseItem[] {
const loaders: webpack.RuleSetUseItem[] = []
Expand Down
92 changes: 68 additions & 24 deletions packages/next/build/webpack/loaders/next-serverless-loader.ts
Expand Up @@ -19,6 +19,7 @@ export type ServerlessLoaderQuery = {
absoluteAppPath: string
absoluteDocumentPath: string
absoluteErrorPath: string
absolute404Path: string
buildId: string
assetPrefix: string
generateEtags: string
Expand All @@ -44,6 +45,7 @@ const nextServerlessLoader: loader.Loader = function () {
absoluteAppPath,
absoluteDocumentPath,
absoluteErrorPath,
absolute404Path,
generateEtags,
poweredByHeader,
basePath,
Expand Down Expand Up @@ -264,28 +266,40 @@ const nextServerlessLoader: loader.Loader = function () {
// check if the locale prefix matches a domain's defaultLocale
// and we're on a locale specific domain if so redirect to that domain
if (detectedDomain) {
const matchedDomain = detectDomainLocale(
i18n.domains,
undefined,
detectedLocale
)
// if (detectedDomain) {
// const matchedDomain = detectDomainLocale(
// i18n.domains,
// undefined,
// detectedLocale
// )
// if (matchedDomain) {
// localeDomainRedirect = \`http\${
// matchedDomain.http ? '' : 's'
// }://\${matchedDomain.domain}\`
// }
// }
} else if (detectedDomain) {
const matchedDomain = detectDomainLocale(
i18n.domains,
undefined,
acceptPreferredLocale
)
if (matchedDomain) {
localeDomainRedirect = \`http\${
matchedDomain.http ? '' : 's'
}://\${matchedDomain.domain}\`
}
if (matchedDomain && matchedDomain.domain !== detectedDomain.domain) {
localeDomainRedirect = \`http\${matchedDomain.http ? '' : 's'}://\${
matchedDomain.domain
}\`
}
}
const denormalizedPagePath = denormalizePagePath(parsedUrl.pathname || '/')
const detectedDefaultLocale =
!detectedLocale ||
detectedLocale.toLowerCase() === defaultLocale.toLowerCase()
const shouldStripDefaultLocale =
detectedDefaultLocale &&
denormalizedPagePath.toLowerCase() === \`/\${i18n.defaultLocale.toLowerCase()}\`
const shouldStripDefaultLocale = false
// detectedDefaultLocale &&
// denormalizedPagePath.toLowerCase() === \`/\${i18n.defaultLocale.toLowerCase()}\`
const shouldAddLocalePrefix =
!detectedDefaultLocale && denormalizedPagePath === '/'
Expand Down Expand Up @@ -482,6 +496,7 @@ const nextServerlessLoader: loader.Loader = function () {
export async function renderReqToHTML(req, res, renderMode, _renderOpts, _params) {
let Document
let Error
let NotFound
;[
getStaticProps,
getServerSideProps,
Expand All @@ -490,7 +505,8 @@ const nextServerlessLoader: loader.Loader = function () {
App,
config,
{ default: Document },
{ default: Error }
{ default: Error },
${absolute404Path ? `{ default: NotFound }, ` : ''}
] = await Promise.all([
getStaticProps,
getServerSideProps,
Expand All @@ -499,7 +515,8 @@ const nextServerlessLoader: loader.Loader = function () {
App,
config,
require('${absoluteDocumentPath}'),
require('${absoluteErrorPath}')
require('${absoluteErrorPath}'),
${absolute404Path ? `require("${absolute404Path}"),` : ''}
])
const fromExport = renderMode === 'export' || renderMode === true;
Expand Down Expand Up @@ -755,14 +772,41 @@ const nextServerlessLoader: loader.Loader = function () {
if (!renderMode) {
if (_nextData || getStaticProps || getServerSideProps) {
sendPayload(req, res, _nextData ? JSON.stringify(renderOpts.pageData) : result, _nextData ? 'json' : 'html', ${
generateEtags === 'true' ? true : false
}, {
private: isPreviewMode,
stateful: !!getServerSideProps,
revalidate: renderOpts.revalidate,
})
return null
if (renderOpts.ssgNotFound) {
res.statusCode = 404
const NotFoundComponent = ${
absolute404Path ? 'NotFound' : 'Error'
}
const errPathname = "${absolute404Path ? '/404' : '/_error'}"
const result = await renderToHTML(req, res, errPathname, parsedUrl.query, Object.assign({}, options, {
getStaticProps: undefined,
getStaticPaths: undefined,
getServerSideProps: undefined,
Component: NotFoundComponent,
err: undefined
}))
sendPayload(req, res, result, 'html', ${
generateEtags === 'true' ? true : false
}, {
private: isPreviewMode,
stateful: !!getServerSideProps,
revalidate: renderOpts.revalidate,
})
return null
} else {
sendPayload(req, res, _nextData ? JSON.stringify(renderOpts.pageData) : result, _nextData ? 'json' : 'html', ${
generateEtags === 'true' ? true : false
}, {
private: isPreviewMode,
stateful: !!getServerSideProps,
revalidate: renderOpts.revalidate,
})
return null
}
}
} else if (isPreviewMode) {
res.setHeader(
Expand Down
19 changes: 11 additions & 8 deletions packages/next/build/webpack/plugins/css-minimizer-plugin.ts
@@ -1,4 +1,5 @@
import { process as minify } from 'cssnano-simple'
import cssnanoSimple from 'cssnano-simple'
import postcss from 'postcss'
import webpack from 'webpack'
import sources from 'webpack-sources'

Expand Down Expand Up @@ -41,13 +42,15 @@ export class CssMinimizerPlugin {
input = asset.source()
}

return minify(input, postcssOptions).then((res) => {
if (res.map) {
return new SourceMapSource(res.css, file, res.map.toJSON())
} else {
return new RawSource(res.css)
}
})
return postcss([cssnanoSimple])
.process(input, postcssOptions)
.then((res) => {
if (res.map) {
return new SourceMapSource(res.css, file, res.map.toJSON())
} else {
return new RawSource(res.css)
}
})
}

apply(compiler: webpack.Compiler) {
Expand Down

0 comments on commit 5fd6a11

Please sign in to comment.