Unverified Commit 78db3475 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Merge branch 'canary' into 11-30-mark_flaky_turbopack_test

parents 81f9e3e5 cc42e437
/** @type {import("next").NextConfig} */
module.exports = {
const nextConfig = {
reactStrictMode: true,
}
module.exports = nextConfig
/** @type {import("next").NextConfig} */
module.exports = {
const nextConfig = {
reactStrictMode: true,
}
module.exports = nextConfig
......@@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "14.0.4-canary.31"
"version": "14.0.4-canary.32"
}
{
"name": "create-next-app",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"keywords": [
"react",
"next",
......
{
"name": "eslint-config-next",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"description": "ESLint configuration used by Next.js.",
"main": "index.js",
"license": "MIT",
......@@ -10,7 +10,7 @@
},
"homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config",
"dependencies": {
"@next/eslint-plugin-next": "14.0.4-canary.31",
"@next/eslint-plugin-next": "14.0.4-canary.32",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0",
"eslint-import-resolver-node": "^0.3.6",
......
{
"name": "@next/eslint-plugin-next",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"description": "ESLint plugin for Next.js.",
"main": "dist/index.js",
"license": "MIT",
......
{
"name": "@next/font",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
......
{
"name": "@next/bundle-analyzer",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
......
{
"name": "@next/codemod",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"license": "MIT",
"repository": {
"type": "git",
......
{
"name": "@next/env",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"keywords": [
"react",
"next",
......
{
"name": "@next/mdx",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"main": "index.js",
"license": "MIT",
"repository": {
......
{
"name": "@next/plugin-storybook",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
......
{
"name": "@next/polyfill-module",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"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",
......
{
"name": "@next/polyfill-nomodule",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
......
{
"name": "@next/swc",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
......
{
"name": "next",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
......@@ -92,7 +92,7 @@
]
},
"dependencies": {
"@next/env": "14.0.4-canary.31",
"@next/env": "14.0.4-canary.32",
"@swc/helpers": "0.5.2",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
......@@ -147,11 +147,11 @@
"@mswjs/interceptors": "0.23.0",
"@napi-rs/cli": "2.16.2",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "14.0.4-canary.31",
"@next/polyfill-nomodule": "14.0.4-canary.31",
"@next/react-dev-overlay": "14.0.4-canary.31",
"@next/react-refresh-utils": "14.0.4-canary.31",
"@next/swc": "14.0.4-canary.31",
"@next/polyfill-module": "14.0.4-canary.32",
"@next/polyfill-nomodule": "14.0.4-canary.32",
"@next/react-dev-overlay": "14.0.4-canary.32",
"@next/react-refresh-utils": "14.0.4-canary.32",
"@next/swc": "14.0.4-canary.32",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "^1.35.1",
"@taskr/clear": "1.1.0",
......
......@@ -15,6 +15,7 @@ import { isDynamicRoute } from '../../../../shared/lib/router/utils'
import { normalizeAppPath } from '../../../../shared/lib/router/utils/app-paths'
import { getPageFromPath } from '../../../entries'
import { devPageFiles } from './shared'
import { getProxiedPluginState } from '../../../build-context'
const PLUGIN_NAME = 'NextTypesPlugin'
......@@ -221,23 +222,23 @@ async function collectNamedSlots(layoutPath: string) {
// By exposing the static route types separately as string literals,
// editors can provide autocompletion for them. However it's currently not
// possible to provide the same experience for dynamic routes.
const routeTypes: Record<
'edge' | 'node' | 'extra',
Record<'static' | 'dynamic', string>
> = {
edge: {
static: '',
dynamic: '',
},
node: {
static: '',
dynamic: '',
},
extra: {
static: '',
dynamic: '',
},
}
const pluginState = getProxiedPluginState({
routeTypes: {
edge: {
static: '',
dynamic: '',
},
node: {
static: '',
dynamic: '',
},
extra: {
static: '',
dynamic: '',
},
} as Record<'edge' | 'node' | 'extra', Record<'static' | 'dynamic', string>>,
})
function formatRouteToRouteType(route: string) {
const isDynamic = isDynamicRoute(route)
......@@ -341,7 +342,8 @@ function addRedirectsRewritesRouteTypes(
for (const normalizedRoute of possibleNormalizedRoutes) {
const { isDynamic, routeType } = formatRouteToRouteType(normalizedRoute)
routeTypes.extra[isDynamic ? 'dynamic' : 'static'] += routeType
pluginState.routeTypes.extra[isDynamic ? 'dynamic' : 'static'] +=
routeType
}
}
}
......@@ -374,8 +376,8 @@ function createRouteDefinitions() {
let dynamicRouteTypes = ''
for (const type of ['edge', 'node', 'extra'] as const) {
staticRouteTypes += routeTypes[type].static
dynamicRouteTypes += routeTypes[type].dynamic
staticRouteTypes += pluginState.routeTypes[type].static
dynamicRouteTypes += pluginState.routeTypes[type].dynamic
}
// If both StaticRoutes and DynamicRoutes are empty, fallback to type 'string'.
......@@ -578,7 +580,7 @@ export class NextTypesPlugin {
const { isDynamic, routeType } = formatRouteToRouteType(route)
routeTypes[this.isEdgeServer ? 'edge' : 'node'][
pluginState.routeTypes[this.isEdgeServer ? 'edge' : 'node'][
isDynamic ? 'dynamic' : 'static'
] += routeType
}
......@@ -667,11 +669,11 @@ export class NextTypesPlugin {
// Clear routes
if (this.isEdgeServer) {
routeTypes.edge.dynamic = ''
routeTypes.edge.static = ''
pluginState.routeTypes.edge.dynamic = ''
pluginState.routeTypes.edge.static = ''
} else {
routeTypes.node.dynamic = ''
routeTypes.node.static = ''
pluginState.routeTypes.node.dynamic = ''
pluginState.routeTypes.node.static = ''
}
compilation.chunkGroups.forEach((chunkGroup) => {
......
......@@ -658,7 +658,9 @@ async function renderToHTMLOrFlightImpl(
: null
// Get the nonce from the incoming request if it has one.
const csp = req.headers['content-security-policy']
const csp =
req.headers['content-security-policy'] ||
req.headers['content-security-policy-report-only']
let nonce: string | undefined
if (csp && typeof csp === 'string') {
nonce = getScriptNonceFromHeader(csp)
......
......@@ -806,6 +806,7 @@ export const defaultConfig: NextConfig = {
process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
? true
: false,
webpackBuildWorker: false,
},
}
......
......@@ -280,9 +280,11 @@ export async function startServer(
console.error(err)
}
process.on('exit', (code) => cleanup(code))
// callback value is signal string, exit with 0
process.on('SIGINT', () => cleanup(0))
process.on('SIGTERM', () => cleanup(0))
if (!process.env.NEXT_MANUAL_SIG_HANDLE) {
// callback value is signal string, exit with 0
process.on('SIGINT', () => cleanup(0))
process.on('SIGTERM', () => cleanup(0))
}
process.on('rejectionHandled', () => {
// It is ok to await a Promise late in Next.js as it allows for better
// prefetching patterns to avoid waterfalls. We ignore loggining these.
......
......@@ -87,7 +87,7 @@ export type Redirect =
}
/**
* `Page` type, use it as a guide to create `pages`.
* `NextPage` type, use it as a guide to create `pages`.
*/
export type NextPage<Props = {}, InitialProps = Props> = NextComponentType<
NextPageContext,
......@@ -140,6 +140,11 @@ export type PageConfig = {
externalResolver?: true
}
env?: Array<string>
/**
* Configures the longest time in seconds a serverless function can process an HTTP
* request before responding.
*/
maxDuration?: number
runtime?: ServerRuntime
unstable_runtimeJS?: false
unstable_JsPreload?: false
......
{
"name": "@next/react-dev-overlay",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"description": "A development-only overlay for developing React applications.",
"repository": {
"url": "vercel/next.js",
......
{
"name": "@next/react-refresh-utils",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
......
{
"name": "@next/third-parties",
"version": "14.0.4-canary.31",
"version": "14.0.4-canary.32",
"repository": {
"url": "vercel/next.js",
"directory": "packages/third-parties"
......@@ -23,7 +23,7 @@
"third-party-capital": "1.0.20"
},
"devDependencies": {
"next": "14.0.4-canary.31",
"next": "14.0.4-canary.32",
"outdent": "0.8.0",
"prettier": "2.5.1"
},
......
......@@ -741,7 +741,7 @@ importers:
packages/eslint-config-next:
dependencies:
'@next/eslint-plugin-next':
specifier: 14.0.4-canary.31
specifier: 14.0.4-canary.32
version: link:../eslint-plugin-next
'@rushstack/eslint-patch':
specifier: ^1.3.3
......@@ -806,7 +806,7 @@ importers:
packages/next:
dependencies:
'@next/env':
specifier: 14.0.4-canary.31
specifier: 14.0.4-canary.32
version: link:../next-env
'@swc/helpers':
specifier: 0.5.2
......@@ -933,19 +933,19 @@ importers:
specifier: 1.1.0
version: 1.1.0
'@next/polyfill-module':
specifier: 14.0.4-canary.31
specifier: 14.0.4-canary.32
version: link:../next-polyfill-module
'@next/polyfill-nomodule':
specifier: 14.0.4-canary.31
specifier: 14.0.4-canary.32
version: link:../next-polyfill-nomodule
'@next/react-dev-overlay':
specifier: 14.0.4-canary.31
specifier: 14.0.4-canary.32
version: link:../react-dev-overlay
'@next/react-refresh-utils':
specifier: 14.0.4-canary.31
specifier: 14.0.4-canary.32
version: link:../react-refresh-utils
'@next/swc':
specifier: 14.0.4-canary.31
specifier: 14.0.4-canary.32
version: link:../next-swc
'@opentelemetry/api':
specifier: 1.6.0
......@@ -1599,7 +1599,7 @@ importers:
version: 1.0.20
devDependencies:
next:
specifier: 14.0.4-canary.31
specifier: 14.0.4-canary.32
version: link:../next
outdent:
specifier: 0.8.0
......
......@@ -24,21 +24,21 @@ const INITIALIZING_TEST_CASES = [
// please make sure this is sorted alphabetically when making changes.
const SKIPPED_TEST_SUITES = {
'test/development/acceptance-app/ReactRefreshRegression.test.ts': [
'ReactRefreshRegression app can fast refresh a page with dynamic rendering',
'ReactRefreshRegression app can fast refresh a page with config',
'ReactRefreshRegression app can fast refresh a page with dynamic rendering',
],
'test/development/acceptance-app/ReactRefreshRequire.test.ts': [
'ReactRefreshRequire app re-runs accepted modules',
'ReactRefreshRequire app propagates a hot update to closest accepted module',
'ReactRefreshRequire app propagates hot update to all inverse dependencies',
'ReactRefreshRequire app re-runs accepted modules',
],
'test/development/acceptance/ReactRefreshLogBox.test.ts': [
'ReactRefreshLogBox turbo conversion to class component (1)',
],
'test/development/acceptance/ReactRefreshRequire.test.ts': [
'ReactRefreshRequire re-runs accepted modules',
'ReactRefreshRequire propagates a hot update to closest accepted module',
'ReactRefreshRequire propagates hot update to all inverse dependencies',
'ReactRefreshRequire re-runs accepted modules',
],
'test/development/basic/hmr.test.ts': [
'basic HMR, basePath: "/docs" Error Recovery should show the error on all pages',
......@@ -47,8 +47,16 @@ const SKIPPED_TEST_SUITES = {
/should automatically fast refresh content when path is added without error/,
/should recover from module not found when paths is updated/,
],
'test/development/middleware-errors/index.test.ts': [
'middleware - development errors when there is a compilation error after boot logs the error correctly',
'middleware - development errors when there is a compilation error from boot logs the error correctly',
],
'test/development/tsconfig-path-reloading/index.test.ts': [
/should automatically fast refresh content when path is added without error/,
'tsconfig-path-reloading tsconfig added after starting dev should load with initial paths config correctly',
],
'test/e2e/app-dir/app-compilation/index.test.ts': [
'app dir HMR should not cause error when removing loading.js',
],
'test/e2e/app-dir/app-css/index.test.ts': [
'app dir - css css support server layouts should support external css imports',
......@@ -68,6 +76,9 @@ const SKIPPED_TEST_SUITES = {
'basePath should 404 when manually adding basePath with router.push',
'basePath should 404 when manually adding basePath with router.replace',
],
'test/e2e/conflicting-app-page-error/index.test.ts': [
'Conflict between app file and pages file should not show error overlay for non conflict pages under app or pages dir',
],
'test/e2e/middleware-rewrites/test/index.test.ts': [
'Middleware Rewrite should have props for afterFiles rewrite to SSG page',
],
......@@ -82,8 +93,8 @@ const SKIPPED_TEST_SUITES = {
'Document and App Client side should detect the changes to pages/_document.js and display it',
],
'test/integration/css/test/css-modules.test.js': [
'CSS Modules Composes Ordering Development Mode should have correct color on index page (on nav from other)',
'CSS Modules Composes Ordering Development Mode should have correct color on index page (on nav from index)',
'CSS Modules Composes Ordering Development Mode should have correct color on index page (on nav from other)',
],
'test/integration/custom-error/test/index.test.js': [/Custom _error/],
'test/integration/dynamic-routing/test/index.test.js': [
......@@ -96,13 +107,41 @@ const SKIPPED_TEST_SUITES = {
'Dynamic Routing production mode should output a routes-manifest correctly',
],
'test/integration/env-config/test/index.test.js': [
'Env Config dev mode with hot reload should provide env for SSG',
'Env Config dev mode with hot reload should provide env correctly for SSR',
'Env Config dev mode with hot reload should provide env correctly for API routes',
'Env Config dev mode with hot reload should provide env correctly for SSR',
'Env Config dev mode with hot reload should provide env for SSG',
],
'test/integration/import-assertion/test/index.test.js': [
/should handle json assertions/,
],
'test/integration/next-image-legacy/unicode/test/index.test.ts': [
/Image Component Unicode Image URL/,
],
'test/integration/next-image-new/unicode/test/index.test.ts': [
/Image Component Unicode Image URL/,
],
}
function checkSorted(arr, name) {
const sorted = [...arr].sort()
if (JSON.stringify(arr) !== JSON.stringify(sorted)) {
console.log(`Expected order of ${name}:`)
for (let i = 0; i < arr.length; i++) {
if (arr[i] === sorted[i]) {
console.log(` ${arr[i]}`)
} else {
console.log(bold().red(`- ${arr[i]}`))
console.log(bold().green(`+ ${sorted[i]}`))
}
}
throw new Error(`${name} is not sorted`)
}
}
checkSorted(Object.keys(SKIPPED_TEST_SUITES), 'SKIPPED_TEST_SUITES')
for (const [key, value] of Object.entries(SKIPPED_TEST_SUITES)) {
checkSorted(value, `SKIPPED_TEST_SUITES['${key}']`)
}
/**
......@@ -234,7 +273,7 @@ async function updatePassingTests() {
if (skippedPassingNames.length > 0) {
console.log(
`${bold().red(filepath)} has ${
`${bold().yellow(filepath)} has ${
skippedPassingNames.length
} passing tests that are marked as skipped:\n${skippedPassingNames
.map((name) => ` - ${name}`)
......
......@@ -9,18 +9,24 @@ createNextDescribe(
files: path.join(__dirname, 'fixture'),
},
({ next }) => {
function fetchWithPolicy(policy: string | null) {
function fetchWithPolicy(policy: string | null, reportOnly?: boolean) {
const cspKey = reportOnly
? 'Content-Security-Policy-Report-Only'
: 'Content-Security-Policy'
return next.fetch('/dashboard', {
headers: policy
? {
'Content-Security-Policy': policy,
[cspKey]: policy,
}
: {},
})
}
async function renderWithPolicy(policy: string | null) {
const res = await fetchWithPolicy(policy)
async function renderWithPolicy(
policy: string | null,
reportOnly?: boolean
) {
const res = await fetchWithPolicy(policy, reportOnly)
expect(res.ok).toBe(true)
......@@ -78,6 +84,36 @@ createNextDescribe(
}
})
it('includes a nonce value with inline scripts when Content-Security-Policy-Report-Only header is defined', async () => {
// A random nonce value, base64 encoded.
const nonce = 'cmFuZG9tCg=='
// Validate all the cases where we could parse the nonce.
const policies = [
`script-src 'nonce-${nonce}'`, // base case
` script-src 'nonce-${nonce}' `, // extra space added around sources and directive
`style-src 'self'; script-src 'nonce-${nonce}'`, // extra directives
`script-src 'self' 'nonce-${nonce}' 'nonce-othernonce'`, // extra nonces
`default-src 'nonce-othernonce'; script-src 'nonce-${nonce}';`, // script and then fallback case
`default-src 'nonce-${nonce}'`, // fallback case
]
for (const policy of policies) {
const $ = await renderWithPolicy(policy, true)
// Find all the script tags without src attributes.
const elements = $('script:not([src])')
// Expect there to be at least 1 script tag without a src attribute.
expect(elements.length).toBeGreaterThan(0)
// Expect all inline scripts to have the nonce value.
elements.each((i, el) => {
expect(el.attribs['nonce']).toBe(nonce)
})
}
})
it('includes a nonce value with bootstrap scripts when Content-Security-Policy header is defined', async () => {
// A random nonce value, base64 encoded.
const nonce = 'cmFuZG9tCg=='
......
import { NextRequest, NextResponse } from 'next/server'
export const runtime = 'edge'
export async function GET(request: NextRequest) {
return NextResponse.json({ hello: 'world' })
}
import React from 'react'
export const dynamic = 'force-dynamic'
export default function Root({ children }: { children: React.ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
import Link from 'next/link'
export default function Home() {
return (
<main>
<Link href="/asdfasdfasdf">Hello, world!</Link>
</main>
)
}
/** @type {import('next').NextConfig} */
module.exports = {
experimental: {
typedRoutes: true,
webpackBuildWorker: true,
},
}
import { NextRequest, NextResponse } from 'next/server'
export const runtime = 'edge'
export async function GET(request: NextRequest) {
return NextResponse.json({ hello: 'world' })
}
import React from 'react'
export const dynamic = 'force-dynamic'
export default function Root({ children }: { children: React.ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
import Link from 'next/link'
export default function Home() {
return (
<main>
<Link href="/">Hello, world!</Link>
</main>
)
}
/** @type {import('next').NextConfig} */
module.exports = {
experimental: {
typedRoutes: true,
webpackBuildWorker: true,
},
}
import { nextBuild } from 'next-test-utils'
import path from 'path'
describe('app dir - typed-routes-with-webpack-worker', () => {
it('builds successfully without errors', async () => {
const output = await nextBuild(
path.join(__dirname, 'good-routes'),
undefined,
{
stdout: true,
stderr: true,
}
)
// check for the experimental flag warning
expect(output.stdout).toContain('webpackBuildWorker')
// should have a successful build
expect(output.code).toBe(0)
// with no errors
expect(output.stderr).not.toContain(`"/" is not an existing route.`)
})
it('builds with valid errors', async () => {
const output = await nextBuild(
path.join(__dirname, 'bad-routes'),
undefined,
{
stdout: true,
stderr: true,
}
)
// check for the experimental flag warning
expect(output.stdout).toContain('webpackBuildWorker')
// should have a failed build
expect(output.code).toBe(1)
// with correct error
expect(output.stderr).toContain(`"/asdfasdfasdf" is not an existing route.`)
})
})
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment