Skip to content

Commit

Permalink
Merge branch 'canary' into add/upgrade-eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Apr 25, 2021
2 parents ac28aed + 08ee60d commit c86b22c
Show file tree
Hide file tree
Showing 24 changed files with 59 additions and 53 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/1.bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Bug Report
description: Create a bug report for the Next.js core
title: 'Bug Report'
labels: 'template: bug'
body:
- type: markdown
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/2.example_bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Example Bug Report
description: Create a bug report for the examples
title: 'Example Bug Report'
labels: 'type: example,template: bug'
body:
- type: markdown
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/3.feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Feature Request
description: Create a feature request for the Next.js core
title: 'Feature Request'
labels: 'template: story'
body:
- type: markdown
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_react_experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
# needs: build
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_PRIVATE_REACT_MODE: concurrent
HEADLESS: true
NEXT_PRIVATE_SKIP_SIZE_TESTS: true
NEXT_PRIVATE_REACT_ROOT: 1
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion examples/api-routes-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ npx create-next-app --example api-routes-rest api-routes-rest-app
yarn create next-app --example api-routes-rest api-routes-rest-app
```

### Deploy to Now
### Deploy to Vercel

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
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.1.4-canary.15"
"version": "10.1.4-canary.16"
}
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.1.4-canary.15",
"version": "10.1.4-canary.16",
"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.1.4-canary.15",
"version": "10.1.4-canary.16",
"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.1.4-canary.15",
"version": "10.1.4-canary.16",
"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.1.4-canary.15",
"version": "10.1.4-canary.16",
"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.1.4-canary.15",
"version": "10.1.4-canary.16",
"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.1.4-canary.15",
"version": "10.1.4-canary.16",
"main": "index.js",
"license": "MIT",
"repository": {
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.1.4-canary.15",
"version": "10.1.4-canary.16",
"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.1.4-canary.15",
"version": "10.1.4-canary.16",
"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.1.4-canary.15",
"version": "10.1.4-canary.16",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,8 @@ export default async function getBaseWebpackConfig(
'process.env.__NEXT_STRICT_MODE': JSON.stringify(
config.reactStrictMode
),
'process.env.__NEXT_REACT_MODE': JSON.stringify(
config.experimental.reactMode
'process.env.__NEXT_REACT_ROOT': JSON.stringify(
config.experimental.reactRoot
),
'process.env.__NEXT_OPTIMIZE_FONTS': JSON.stringify(
config.optimizeFonts && !dev
Expand Down
27 changes: 14 additions & 13 deletions packages/next/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ export function renderError(renderErrorProps: RenderErrorProps): Promise<any> {
}

let reactRoot: any = null
let shouldUseHydrate: boolean = typeof ReactDOM.hydrate === 'function'
let shouldHydrate: boolean = typeof ReactDOM.hydrate === 'function'

function renderReactElement(
domEl: HTMLElement,
fn: (cb: () => void) => JSX.Element
Expand All @@ -504,24 +505,24 @@ function renderReactElement(
performance.mark('beforeRender')
}

const reactEl = fn(
shouldUseHydrate ? markHydrateComplete : markRenderComplete
)
if (process.env.__NEXT_REACT_MODE !== 'legacy') {
const reactEl = fn(shouldHydrate ? markHydrateComplete : markRenderComplete)
if (process.env.__NEXT_REACT_ROOT) {
if (!reactRoot) {
const opts = { hydrate: shouldUseHydrate }
reactRoot =
process.env.__NEXT_REACT_MODE === 'concurrent'
? (ReactDOM as any).unstable_createRoot(domEl, opts)
: (ReactDOM as any).unstable_createBlockingRoot(domEl, opts)
const createRootName =
typeof (ReactDOM as any).unstable_createRoot === 'function'
? 'unstable_createRoot'
: 'createRoot'
reactRoot = (ReactDOM as any)[createRootName](domEl, {
hydrate: shouldHydrate,
})
}
reactRoot.render(reactEl)
shouldUseHydrate = false
shouldHydrate = false
} else {
// The check for `.hydrate` is there to support React alternatives like preact
if (shouldUseHydrate) {
if (shouldHydrate) {
ReactDOM.hydrate(reactEl, domEl)
shouldUseHydrate = false
shouldHydrate = false
} else {
ReactDOM.render(reactEl, domEl)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/lib/typescript/writeConfigurationDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export async function writeConfigurationDefaults(
chalk.green(
`We detected TypeScript in your project and reconfigured your ${chalk.bold(
'tsconfig.json'
)} file for you.`
)} file for you. Strict-mode is set to ${chalk.bold('false')} by default.`
) + '\n'
)
if (suggestedActions.length) {
Expand Down
3 changes: 2 additions & 1 deletion packages/next/next-server/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type NextConfig = { [key: string]: any } & {
skipValidation?: boolean
}
turboMode: boolean
reactRoot: boolean
}
}

Expand Down Expand Up @@ -104,7 +105,6 @@ export const defaultConfig: NextConfig = {
plugins: false,
profiling: false,
sprFlushToDisk: true,
reactMode: (process.env.NEXT_PRIVATE_REACT_MODE as any) || 'legacy',
workerThreads: false,
pageEnv: false,
optimizeImages: false,
Expand All @@ -115,6 +115,7 @@ export const defaultConfig: NextConfig = {
externalDir: false,
serialWebpackBuild: false,
turboMode: false,
reactRoot: Number(process.env.NEXT_PRIVATE_REACT_ROOT) > 0,
},
future: {
strictPostcssConfiguration: false,
Expand Down
25 changes: 13 additions & 12 deletions packages/next/next-server/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { loadEnvConfig } from '@next/env'
export { DomainLocales, NextConfig, normalizeConfig } from './config-shared'

const targets = ['server', 'serverless', 'experimental-serverless-trace']
const reactModes = ['legacy', 'blocking', 'concurrent']

const experimentalWarning = execOnce(() => {
Log.warn(chalk.bold('You have enabled experimental feature(s).'))
Expand All @@ -36,6 +35,19 @@ function assignDefaults(userConfig: { [key: string]: any }) {
delete userConfig.exportTrailingSlash
}

if (typeof userConfig.experimental?.reactMode !== 'undefined') {
console.warn(
chalk.yellow.bold('Warning: ') +
'The experimental "reactMode" option has been replaced with "reactRoot". Please update your next.config.js.'
)
if (typeof userConfig.experimental?.reactRoot === 'undefined') {
userConfig.experimental.reactRoot = ['concurrent', 'blocking'].includes(
userConfig.experimental.reactMode
)
}
delete userConfig.experimental.reactMode
}

const config = Object.keys(userConfig).reduce<{ [key: string]: any }>(
(currentConfig, key) => {
const value = userConfig[key]
Expand Down Expand Up @@ -435,17 +447,6 @@ export default async function loadConfig(
: canonicalBase) || ''
}

if (
userConfig.experimental?.reactMode &&
!reactModes.includes(userConfig.experimental.reactMode)
) {
throw new Error(
`Specified React Mode is invalid. Provided: ${
userConfig.experimental.reactMode
} should be one of ${reactModes.join(', ')}`
)
}

if (hasNextSupport) {
userConfig.target = process.env.NEXT_PRIVATE_TARGET || 'server'
}
Expand Down
12 changes: 6 additions & 6 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "10.1.4-canary.15",
"version": "10.1.4-canary.16",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -64,10 +64,10 @@
"dependencies": {
"@babel/runtime": "7.12.5",
"@hapi/accept": "5.0.1",
"@next/env": "10.1.4-canary.15",
"@next/polyfill-module": "10.1.4-canary.15",
"@next/react-dev-overlay": "10.1.4-canary.15",
"@next/react-refresh-utils": "10.1.4-canary.15",
"@next/env": "10.1.4-canary.16",
"@next/polyfill-module": "10.1.4-canary.16",
"@next/react-dev-overlay": "10.1.4-canary.16",
"@next/react-refresh-utils": "10.1.4-canary.16",
"@opentelemetry/api": "0.14.0",
"assert": "2.0.0",
"ast-types": "0.13.2",
Expand Down Expand Up @@ -150,7 +150,7 @@
"@babel/preset-typescript": "7.12.7",
"@babel/traverse": "^7.12.10",
"@babel/types": "7.12.12",
"@next/polyfill-nomodule": "10.1.4-canary.15",
"@next/polyfill-nomodule": "10.1.4-canary.16",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-dev-overlay",
"version": "10.1.4-canary.15",
"version": "10.1.4-canary.16",
"description": "A development-only overlay for developing React applications.",
"repository": {
"url": "vercel/next.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "10.1.4-canary.15",
"version": "10.1.4-canary.16",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
8 changes: 7 additions & 1 deletion test/integration/link-ref/pages/click-away-race-condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ const useClickAway = (ref, onClickAway) => {
el && !el.contains(event.target) && onClickAway(event)
}

document.addEventListener('click', handler)
let timeoutID = setTimeout(() => {
timeoutID = null
document.addEventListener('click', handler)
}, 0)

return () => {
if (timeoutID != null) {
clearTimeout(timeoutID)
}
document.removeEventListener('click', handler)
}
}, [onClickAway, ref])
Expand Down

0 comments on commit c86b22c

Please sign in to comment.