Skip to content

Commit

Permalink
Merge branch 'canary' into eslint-update-7
Browse files Browse the repository at this point in the history
  • Loading branch information
housseindjirdeh committed Jul 30, 2021
2 parents a30a405 + dd7a54c commit 25d271b
Show file tree
Hide file tree
Showing 25 changed files with 111 additions and 52 deletions.
7 changes: 6 additions & 1 deletion examples/with-passport-and-next-connect/pages/api/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import nextConnect from 'next-connect'
import auth from '../../middleware/auth'
import { deleteUser, updateUserByUsername } from '../../lib/db'
import { deleteUser, createUser, updateUserByUsername } from '../../lib/db'

const handler = nextConnect()

Expand All @@ -13,6 +13,11 @@ handler
// res.json({ user: { name, username, favoriteColor } })
res.json({ user: req.user })
})
.post((req, res) => {
const { username, password, name } = req.body
createUser(req, { username, password, name })
res.status(200).json({ success: true, message: 'created new user' })
})
.use((req, res, next) => {
// handlers after this (PUT, DELETE) all require an authenticated user
// This middleware to check if user is authenticated before continuing
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": "11.0.2-canary.23"
"version": "11.0.2-canary.24"
}
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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"directory": "packages/eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "11.0.2-canary.23",
"@next/eslint-plugin-next": "11.0.2-canary.24",
"@rushstack/eslint-patch": "^1.0.6",
"@typescript-eslint/parser": "^4.20.0",
"eslint-import-resolver-node": "^0.3.4",
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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/compiled/terser/bundle.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/next/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ export const ESLINT_PROMPT_VALUES = [
config: null,
},
]

14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -65,10 +65,10 @@
"dependencies": {
"@babel/runtime": "7.12.5",
"@hapi/accept": "5.0.2",
"@next/env": "11.0.2-canary.23",
"@next/polyfill-module": "11.0.2-canary.23",
"@next/react-dev-overlay": "11.0.2-canary.23",
"@next/react-refresh-utils": "11.0.2-canary.23",
"@next/env": "11.0.2-canary.24",
"@next/polyfill-module": "11.0.2-canary.24",
"@next/react-dev-overlay": "11.0.2-canary.24",
"@next/react-refresh-utils": "11.0.2-canary.24",
"@node-rs/helper": "1.2.1",
"assert": "2.0.0",
"ast-types": "0.13.2",
Expand Down Expand Up @@ -155,7 +155,7 @@
"@babel/traverse": "^7.12.10",
"@babel/types": "7.12.12",
"@napi-rs/cli": "1.1.0",
"@next/polyfill-nomodule": "11.0.2-canary.23",
"@next/polyfill-nomodule": "11.0.2-canary.24",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand Down Expand Up @@ -240,7 +240,7 @@
"string-hash": "1.1.3",
"strip-ansi": "6.0.0",
"taskr": "1.1.0",
"terser": "5.5.1",
"terser": "5.7.1",
"text-table": "0.2.0",
"typescript": "4.3.4",
"unistore": "3.4.1",
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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"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": "11.0.2-canary.23",
"version": "11.0.2-canary.24",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
1 change: 1 addition & 0 deletions test/integration/react-18/prerelease/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
// Use react 18
alias['react'] = require.resolve('react-18')
alias['react-dom'] = require.resolve('react-dom-18')
alias['react-dom/server'] = require.resolve('react-dom-18/server')

return config
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/integration/react-18/prerelease/pages/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Bar() {
return <div>bar</div>
}
12 changes: 11 additions & 1 deletion test/integration/react-18/prerelease/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { Suspense } from 'react'
import Bar from './bar'

export default function Index() {
if (typeof window !== 'undefined') {
window.didHydrate = true
}
return <p>Hello</p>
return (
<div>
<p>Hello</p>
<Suspense fallback={'loading...'}>
<Bar />
</Suspense>
</div>
)
}
19 changes: 14 additions & 5 deletions test/integration/react-18/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import {
findPort,
killApp,
launchApp,
runNextCommand,
nextBuild,
nextStart,
} from 'next-test-utils'

jest.setTimeout(1000 * 60 * 5)

// overrides react and react-dom to v18
const nodeArgs = ['-r', join(__dirname, 'require-hook.js')]
const dirSupported = join(__dirname, '../supported')
const dirPrerelease = join(__dirname, '../prerelease')

Expand All @@ -22,9 +23,10 @@ const UNSUPPORTED_PRERELEASE =
const USING_CREATE_ROOT = 'Using the createRoot API for React'

async function getBuildOutput(dir) {
const { stdout, stderr } = await runNextCommand(['build', dir], {
const { stdout, stderr } = await nextBuild(dir, [], {
stdout: true,
stderr: true,
nodeArgs,
})
return stdout + stderr
}
Expand All @@ -43,6 +45,7 @@ async function getDevOutput(dir) {
onStderr(msg) {
stderr += msg
},
nodeArgs,
})
await killApp(instance)
return stdout + stderr
Expand Down Expand Up @@ -83,11 +86,17 @@ describe('React 18 Support', () => {
let appPort
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await nextBuild(appDir, [dirPrerelease])
await nextBuild(appDir, [dirPrerelease], {
nodeArgs,
stdout: true,
stderr: true,
})
appPort = await findPort()
app = await nextStart(appDir, appPort)
app = await nextStart(appDir, appPort, { nodeArgs })
})
afterAll(async () => {
await killApp(app)
})
afterAll(async () => await killApp(app))
it('hydrates correctly for normal page', async () => {
const browser = await webdriver(appPort, '/')
expect(await browser.eval('window.didHydrate')).toBe(true)
Expand Down
14 changes: 14 additions & 0 deletions test/integration/react-18/test/require-hook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mod = require('module')

const hookPropertyMap = new Map([
['react', 'react-18'],
['react-dom', 'react-dom-18'],
['react-dom/server', 'react-dom-18/server'],
])

const resolveFilename = mod._resolveFilename
mod._resolveFilename = function (request, parent, isMain, options) {
const hookResolved = hookPropertyMap.get(request)
if (hookResolved) request = hookResolved
return resolveFilename.call(mod, request, parent, isMain, options)
}
29 changes: 19 additions & 10 deletions test/lib/next-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,16 @@ export function runNextCommand(argv, options = {}) {

return new Promise((resolve, reject) => {
console.log(`Running command "next ${argv.join(' ')}"`)
const instance = spawn('node', ['--no-deprecation', nextBin, ...argv], {
...options.spawnOptions,
cwd,
env,
stdio: ['ignore', 'pipe', 'pipe'],
})
const instance = spawn(
'node',
[...(options.nodeArgs || []), '--no-deprecation', nextBin, ...argv],
{
...options.spawnOptions,
cwd,
env,
stdio: ['ignore', 'pipe', 'pipe'],
}
)

if (typeof options.instance === 'function') {
options.instance(instance)
Expand Down Expand Up @@ -176,11 +180,16 @@ export function runNextCommandDev(argv, stdOut, opts = {}) {
...opts.env,
}

const nodeArgs = opts.nodeArgs || []
return new Promise((resolve, reject) => {
const instance = spawn('node', ['--no-deprecation', nextBin, ...argv], {
cwd,
env,
})
const instance = spawn(
'node',
[...nodeArgs, '--no-deprecation', nextBin, ...argv],
{
cwd,
env,
}
)
let didResolve = false

function handleStdout(data) {
Expand Down
31 changes: 20 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16052,21 +16052,21 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.7, rc@^1.2.8:
strip-json-comments "~2.0.1"

"react-18@npm:react@next":
version "18.0.0-alpha-73ffce1b6-20210624"
resolved "https://registry.yarnpkg.com/react/-/react-18.0.0-alpha-73ffce1b6-20210624.tgz#d9fb8700c6fad8de752ec0427f2ae3a941eea951"
integrity sha512-Qaj2vhrMlYc169Yh0gXBB7WeKWMeIVx99JnuouuT71Jku2Cly9TxAWurc+h6PSgz/qjjmDA2NOtHCb6mGlmzGA==
version "18.0.0-alpha-c76e4dbbc-20210722"
resolved "https://registry.yarnpkg.com/react/-/react-18.0.0-alpha-c76e4dbbc-20210722.tgz#a1591fa4926bb1c514552f77efcc4b4744448f2f"
integrity sha512-dtRjRJVHPA25oi29ZFEuLX6R7Rdk5ikCamiDRD0LCB1IpR5hiGKGcNjSxU/rN7rAxs8iRggi15Fg9k1jAK7oBQ==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"

"react-dom-18@npm:react-dom@next":
version "18.0.0-alpha-73ffce1b6-20210624"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.0.0-alpha-73ffce1b6-20210624.tgz#3d789e4f3446abc685a7754c8dc74dea0ffb4247"
integrity sha512-TgA+VhVas3mJdhy6AQLXnPzBN2JeNKC7EGhLKU11XOxUODCGQ94nyT04i1ta2R3Fv0QevMLp0Wb5hccan0wMEg==
version "18.0.0-alpha-c76e4dbbc-20210722"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.0.0-alpha-c76e4dbbc-20210722.tgz#4fc4518926332983788d48aaad0c6ca5e5d806e5"
integrity sha512-lV/+kWzfPq8HLdFnDN1UrJ5blXVFRYCrdOJyZyr9YMZODBl63kpPR7gtszSC4lWiPiMw6K8X+4a3UFU96L7pHQ==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
scheduler "0.21.0-alpha-73ffce1b6-20210624"
scheduler "0.21.0-alpha-c76e4dbbc-20210722"

[email protected]:
version "17.0.2"
Expand Down Expand Up @@ -17100,10 +17100,10 @@ saxes@^5.0.1:
dependencies:
xmlchars "^2.2.0"

[email protected]73ffce1b6-20210624:
version "0.21.0-alpha-73ffce1b6-20210624"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.21.0-alpha-73ffce1b6-20210624.tgz#6fff95e26af73cfaa365b68fa3b68c4c66dfe347"
integrity sha512-7SXTiepGRo63F5Yp/fxLhZDYi5TInsqjnMTYF6GwtunUGAwyuK4V/AFiF0Q1gtB32U/e+C+OE4SSj9LtBYBjYw==
[email protected]c76e4dbbc-20210722:
version "0.21.0-alpha-c76e4dbbc-20210722"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.21.0-alpha-c76e4dbbc-20210722.tgz#7172827a6ed0829e41d1c07cbbf7d9fea6b018ba"
integrity sha512-X4Xv2zq1OXxsQNR48reXnOQ9kGnS/mY0cCAusJ6Sm/JBUT83+zetG2sPZPFQSS1np2zkmgMa4+f5H/t2U6AW6Q==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
Expand Down Expand Up @@ -18424,6 +18424,15 @@ [email protected], terser@^5.0.0:
source-map "~0.7.2"
source-map-support "~0.5.19"

[email protected]:
version "5.7.1"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.7.1.tgz#2dc7a61009b66bb638305cb2a824763b116bf784"
integrity sha512-b3e+d5JbHAe/JSjwsC3Zn55wsBIM7AsHLjKxT31kGCldgbpFePaFo+PiddtO6uwRZWRw7sPXmAN8dTW61xmnSg==
dependencies:
commander "^2.20.0"
source-map "~0.7.2"
source-map-support "~0.5.19"

terser@^4.1.2:
version "4.8.0"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.0.tgz#63056343d7c70bb29f3af665865a46fe03a0df17"
Expand Down

0 comments on commit 25d271b

Please sign in to comment.