Skip to content

Commit

Permalink
Merge branch 'canary' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 17, 2020
2 parents e626a2c + cfca41c commit b5d0aae
Show file tree
Hide file tree
Showing 32 changed files with 803 additions and 220 deletions.
20 changes: 12 additions & 8 deletions docs/api-reference/next/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ export default function Page() {

You can listen to different events happening inside the Next.js Router. Here's a list of supported events:

- `routeChangeStart(url)` - Fires when a route starts to change
- `routeChangeComplete(url)` - Fires when a route changed completely
- `routeChangeError(err, url)` - Fires when there's an error when changing routes, or a route load is cancelled
- `routeChangeStart(url, { shallow })` - Fires when a route starts to change
- `routeChangeComplete(url, { shallow })` - Fires when a route changed completely
- `routeChangeError(err, url, { shallow })` - Fires when there's an error when changing routes, or a route load is cancelled
- `err.cancelled` - Indicates if the navigation was cancelled
- `beforeHistoryChange(url)` - Fires just before changing the browser's history
- `hashChangeStart(url)` - Fires when the hash will change but not the page
- `hashChangeComplete(url)` - Fires when the hash has changed but not the page
- `beforeHistoryChange(url, { shallow })` - Fires just before changing the browser's history
- `hashChangeStart(url, { shallow })` - Fires when the hash will change but not the page
- `hashChangeComplete(url, { shallow })` - Fires when the hash has changed but not the page

> **Note:** Here `url` is the URL shown in the browser, including the [`basePath`](/docs/api-reference/next.config.js/basepath.md).
Expand All @@ -332,8 +332,12 @@ export default function MyApp({ Component, pageProps }) {
const router = useRouter()

useEffect(() => {
const handleRouteChange = (url) => {
console.log('App is changing to: ', url)
const handleRouteChange = (url, { shallow }) => {
console.log(
`App is changing to ${url} ${
shallow ? 'with' : 'without'
} shallow routing`
)
}

router.events.on('routeChangeStart', handleRouteChange)
Expand Down
2 changes: 1 addition & 1 deletion examples/with-supabase-auth-realtime-db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is a full-stack Slack clone example using:

![Demo animation gif](./docs/slack-clone-demo.gif)

This example is a clone of the [Slack Clone example](https://github.com/supabase/supabase/tree/master/examples/slack-clone) in the supabase repo, feel free to check it out!
This example is a clone of the [Slack Clone example](https://github.com/supabase/supabase/tree/master/examples/nextjs-slack-clone) in the supabase repo, feel free to check it out!

## Deploy your own

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "10.0.4-canary.6"
"version": "10.0.4-canary.7"
}
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": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"keywords": [
"react",
"next",
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": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"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": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-sentry"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "10.0.4-canary.6",
"version": "10.0.4-canary.7",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
69 changes: 64 additions & 5 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ import { loadEnvConfig } from '@next/env'
import { recursiveDelete } from '../lib/recursive-delete'
import { verifyTypeScriptSetup } from '../lib/verifyTypeScriptSetup'
import {
BUILD_ID_FILE,
BUILD_MANIFEST,
CLIENT_STATIC_FILES_PATH,
EXPORT_DETAIL,
EXPORT_MARKER,
FONT_MANIFEST,
IMAGES_MANIFEST,
PAGES_MANIFEST,
PHASE_PRODUCTION_BUILD,
PRERENDER_MANIFEST,
REACT_LOADABLE_MANIFEST,
ROUTES_MANIFEST,
SERVERLESS_DIRECTORY,
SERVER_DIRECTORY,
SERVER_FILES_MANIFEST,
} from '../next-server/lib/constants'
import {
getRouteRegex,
Expand Down Expand Up @@ -343,6 +347,39 @@ export default async function build(
'utf8'
)

const manifestPath = path.join(
distDir,
isLikeServerless ? SERVERLESS_DIRECTORY : SERVER_DIRECTORY,
PAGES_MANIFEST
)

const requiredServerFiles = {
version: 1,
config: {
...config,
compress: false,
configFile: undefined,
},
files: [
ROUTES_MANIFEST,
path.relative(distDir, manifestPath),
BUILD_MANIFEST,
PRERENDER_MANIFEST,
REACT_LOADABLE_MANIFEST,
path.join(
isLikeServerless ? SERVERLESS_DIRECTORY : SERVER_DIRECTORY,
FONT_MANIFEST
),
BUILD_ID_FILE,
].map((file) => path.join(config.distDir, file)),
ignore: [
path.relative(
dir,
path.join(path.dirname(require.resolve('sharp')), '**/*')
),
],
}

const configs = await Promise.all([
getBaseWebpackConfig(dir, {
tracer,
Expand Down Expand Up @@ -465,11 +502,6 @@ export default async function build(
prefixText: `${Log.prefixes.info} Collecting page data`,
})

const manifestPath = path.join(
distDir,
isLikeServerless ? SERVERLESS_DIRECTORY : SERVER_DIRECTORY,
PAGES_MANIFEST
)
const buildManifestPath = path.join(distDir, BUILD_MANIFEST)

const ssgPages = new Set<string>()
Expand Down Expand Up @@ -515,6 +547,8 @@ export default async function build(
false
))

let hasSsrAmpPages = false

const analysisBegin = process.hrtime()
await Promise.all(
pageKeys.map(async (page) => {
Expand Down Expand Up @@ -575,6 +609,13 @@ export default async function build(
config.i18n?.defaultLocale
)

if (
workerResult.isStatic === false &&
(workerResult.isHybridAmp || workerResult.isAmpOnly)
) {
hasSsrAmpPages = true
}

if (workerResult.isHybridAmp) {
isHybridAmp = true
hybridAmpPages.add(page)
Expand Down Expand Up @@ -637,6 +678,18 @@ export default async function build(
)
staticCheckWorkers.end()

if (!hasSsrAmpPages) {
requiredServerFiles.ignore.push(
path.relative(
dir,
path.join(
path.dirname(require.resolve('@ampproject/toolbox-optimizer')),
'**/*'
)
)
)
}

if (serverPropsPages.size > 0 || ssgPages.size > 0) {
// We update the routes manifest after the build with the
// data routes since we can't determine these until after build
Expand Down Expand Up @@ -712,6 +765,12 @@ export default async function build(

await writeBuildId(distDir, buildId)

await promises.writeFile(
path.join(distDir, SERVER_FILES_MANIFEST),
JSON.stringify(requiredServerFiles),
'utf8'
)

const finalPrerenderRoutes: { [route: string]: SsgRoute } = {}
const tbdPrerenderRoutes: string[] = []
let ssgNotFoundPaths: string[] = []
Expand Down
Loading

0 comments on commit b5d0aae

Please sign in to comment.