Skip to content

Commit

Permalink
Merge branch 'canary' into shuding/next-1110-server-css-hmr-not-worki…
Browse files Browse the repository at this point in the history
…ng-properly-with
  • Loading branch information
shuding committed May 9, 2023
2 parents 592111e + 201ab71 commit 6954bd4
Show file tree
Hide file tree
Showing 38 changed files with 698 additions and 501 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/trigger_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ on:
workflow_dispatch:
inputs:
releaseType:
description: stable or canary (case sensitive)?
description: stable or canary?
required: true
type: string
type: choice
options:
- canary
- stable

semverType:
description: patch, minor, or major (case sensitive)?
type: string
description: semver type?
type: choice
options:
- patch
- minor
- major

secrets:
RELEASE_BOT_TOKEN:
Expand Down
2 changes: 1 addition & 1 deletion bench/rendering/pages/stateless-big.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default () => {
}

const items = () => {
var out = new Array(10000)
const out = new Array(10000)
for (let i = 0; i < out.length; i++) {
out[i] = <li key={i}>This is row {i + 1}</li>
}
Expand Down
10 changes: 9 additions & 1 deletion errors/react-hydration-error.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,18 @@ Common causes with css-in-js libraries:
- When using other css-in-js libraries
- Similar to Styled Components / Emotion css-in-js libraries generally need configuration specified in their examples in the [examples directory](https://github.com/vercel/next.js/tree/canary/examples)

Local Overrides
Local Overrides:

It's possible you may have [Local Overrides enabled in Chrome devtools](https://developer.chrome.com/blog/new-in-devtools-65/#overrides). With this enabled, the HTML served will be different from what the SSR emitted. It also won't show up in view-source, so you may be left wondering what is going on.

Common causes on iOS:

- iOS attempts to detect phone numbers, email addressees and other data in text content and convert them into links, which can [lead to hydration mismatches](https://github.com/vercel/next.js/issues/38290). This can be disabled with the following `meta` tag:

```
<meta name="format-detection" content="telephone=no, date=no, email=no, address=no" />
```

### Useful Links

- [React Hydration Documentation](https://react.dev/reference/react-dom/client/hydrateRoot)
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "13.4.2-canary.2"
"version": "13.4.2-canary.3"
}
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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"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": "13.4.2-canary.2",
"@next/eslint-plugin-next": "13.4.2-canary.3",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.42.0",
"eslint-import-resolver-node": "^0.3.6",
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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"description": "ESLint plugin for NextJS.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/font",
"version": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"license": "MIT",
"repository": {
"type": "git",
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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"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-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"private": true,
"scripts": {
"clean": "rm -rf ./native/*",
Expand Down
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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -83,7 +83,7 @@
]
},
"dependencies": {
"@next/env": "13.4.2-canary.2",
"@next/env": "13.4.2-canary.3",
"@swc/helpers": "0.5.1",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
Expand Down Expand Up @@ -143,11 +143,11 @@
"@jest/types": "29.5.0",
"@napi-rs/cli": "2.14.7",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "13.4.2-canary.2",
"@next/polyfill-nomodule": "13.4.2-canary.2",
"@next/react-dev-overlay": "13.4.2-canary.2",
"@next/react-refresh-utils": "13.4.2-canary.2",
"@next/swc": "13.4.2-canary.2",
"@next/polyfill-module": "13.4.2-canary.3",
"@next/polyfill-nomodule": "13.4.2-canary.3",
"@next/react-dev-overlay": "13.4.2-canary.3",
"@next/react-refresh-utils": "13.4.2-canary.3",
"@next/swc": "13.4.2-canary.3",
"@opentelemetry/api": "1.4.1",
"@segment/ajv-human-errors": "2.1.2",
"@taskr/clear": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export default async function nextFontLoader(this: any) {
postcss: getPostcss,
} = this.getOptions()

if (assetPrefix && !/^\/|https?:\/\//.test(assetPrefix)) {
const err = new Error(
'assetPrefix must start with a leading slash or be an absolute URL(http:// or https://)'
)
err.name = 'NextFontError'
callback(err)
return
}

/**
* Emit font files to .next/static/media as [hash].[ext].
*
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/client/components/error.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'

const styles: { [k: string]: React.CSSProperties } = {
const styles: Record<string, React.CSSProperties> = {
error: {
// https://github.com/sindresorhus/modern-normalize/blob/main/modern-normalize.css#L38-L52
fontFamily:
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/pages/_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function _getInitialProps({
return { statusCode }
}

const styles: { [k: string]: React.CSSProperties } = {
const styles: Record<string, React.CSSProperties> = {
error: {
// https://github.com/sindresorhus/modern-normalize/blob/main/modern-normalize.css#L38-L52
fontFamily:
Expand Down
11 changes: 11 additions & 0 deletions packages/next/src/server/node-polyfill-crypto.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-env jest */
import './node-polyfill-crypto'

describe('node-polyfill-crypto', () => {
test('overwrite crypto', async () => {
expect(global.crypto).not.toBeUndefined()
const a = {} as Crypto
global.crypto = a
expect(global.crypto).toBe(a)
})
})
17 changes: 12 additions & 5 deletions packages/next/src/server/node-polyfill-crypto.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
// Polyfill crypto() in the Node.js environment

if (!(global as any).crypto) {
function getCryptoImpl() {
return require('node:crypto').webcrypto
}
if (!global.crypto) {
let webcrypto: Crypto | undefined

Object.defineProperty(global, 'crypto', {
enumerable: false,
configurable: true,
get() {
return getCryptoImpl()
if (!webcrypto) {
webcrypto = require('node:crypto').webcrypto
}
return webcrypto
},
set(value: Crypto) {
webcrypto = value
},
})
}
7 changes: 6 additions & 1 deletion packages/next/src/shared/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ function getMiddlewareData<T extends FetchDataOutput>(
) {
const parsedSource = getNextPathnameInfo(
parseRelativeUrl(source).pathname,
{ parseData: true }
{
nextConfig: process.env.__NEXT_HAS_REWRITES
? undefined
: nextConfig,
parseData: true,
}
)

as = addBasePath(parsedSource.pathname)
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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"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": "13.4.2-canary.2",
"version": "13.4.2-canary.3",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

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

30 changes: 28 additions & 2 deletions test/e2e/app-dir/actions/app-action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ createNextDescribe(
{
files: __dirname,
},
({ next, isNextDev }) => {
({ next, isNextDev, isNextStart }) => {
it('should handle basic actions correctly', async () => {
const browser = await next.browser('/server')

Expand Down Expand Up @@ -59,6 +59,32 @@ createNextDescribe(
}, 'same')
})

it('should support headers in client imported actions', async () => {
const logs: string[] = []
next.on('stdout', (log) => {
logs.push(log)
})
next.on('stderr', (log) => {
logs.push(log)
})

const currentTimestamp = Date.now()

const browser = await next.browser('/client')
await browser.elementByCss('#get-header').click()
await check(() => {
return logs.some((log) =>
log.includes('accept header: text/x-component')
)
? 'yes'
: ''
}, 'yes')

expect(
await browser.eval('+document.cookie.match(/test-cookie=(\\d+)/)[1]')
).toBeGreaterThanOrEqual(currentTimestamp)
})

it('should support setting cookies in route handlers with the correct overrides', async () => {
const res = await next.fetch('/handler')
const setCookieHeader = res.headers.get('set-cookie') as string[]
Expand Down Expand Up @@ -172,7 +198,7 @@ createNextDescribe(
await check(() => browser.elementByCss('h1').text(), '3')
})

if (!isNextDev) {
if (isNextStart) {
it('should not expose action content in sourcemaps', async () => {
const sourcemap = (
await fs.readdir(
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/app-dir/actions/app/client/actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
'use server'

import { redirect } from 'next/navigation'
import { headers, cookies } from 'next/headers'

export async function getHeaders() {
console.log('accept header:', headers().get('accept'))
cookies().set('test-cookie', Date.now())
}

export async function inc(value) {
return value + 1
Expand Down

0 comments on commit 6954bd4

Please sign in to comment.