Unverified Commit a5f8382e authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Rename page runtime edge to experimental-edge (#38041)

* Rename page runtime edge to experimental-edge

* fix ut

* fix lint

* PageRuntime -> ServerRuntime

* rename constant
parent 252d3b72
...@@ -22,7 +22,7 @@ module.exports = { ...@@ -22,7 +22,7 @@ module.exports = {
} }
``` ```
Using `runtime` also enables [Streaming SSR](/docs/advanced-features/react-18/streaming). When setting `runtime` to `'edge'`, the server will be running entirely in the [Edge Runtime](https://nextjs.org/docs/api-reference/edge-runtime). Using `runtime` also enables [Streaming SSR](/docs/advanced-features/react-18/streaming). When setting `runtime` to `'experimental-edge'`, the server will be running entirely in the [Edge Runtime](https://nextjs.org/docs/api-reference/edge-runtime).
Now, you can start using React Server Components in Next.js. [See our example](https://github.com/vercel/next-rsc-demo) for more information. Now, you can start using React Server Components in Next.js. [See our example](https://github.com/vercel/next-rsc-demo) for more information.
......
...@@ -8,7 +8,7 @@ If you have [React 18](/docs/advanced-features/react-18/overview) installed, the ...@@ -8,7 +8,7 @@ If you have [React 18](/docs/advanced-features/react-18/overview) installed, the
## Global Runtime Option ## Global Runtime Option
You can set the experimental option `runtime` to either `'nodejs'` or `'edge'` in your `next.config.js` file: You can set the experimental option `runtime` to either `'nodejs'` or `'experimental-edge'` in your `next.config.js` file:
```jsx ```jsx
// next.config.js // next.config.js
...@@ -23,7 +23,7 @@ This option determines which runtime should be used as the default rendering run ...@@ -23,7 +23,7 @@ This option determines which runtime should be used as the default rendering run
## Page Runtime Option ## Page Runtime Option
On each page, you can optionally export a `runtime` config set to either `'nodejs'` or `'edge'`: On each page, you can optionally export a `runtime` config set to either `'nodejs'` or `'experimental-edge'`:
```jsx ```jsx
export const config = { export const config = {
......
...@@ -16,7 +16,7 @@ import type { ...@@ -16,7 +16,7 @@ import type {
/** /**
* Extracts the value of an exported const variable named `exportedName` * Extracts the value of an exported const variable named `exportedName`
* (e.g. "export const config = { runtime: 'edge' }") from swc's AST. * (e.g. "export const config = { runtime: 'experimental-edge' }") from swc's AST.
* The value must be one of (or throws UnsupportedValueError): * The value must be one of (or throws UnsupportedValueError):
* - string * - string
* - boolean * - boolean
......
import type { PageRuntime } from '../../server/config-shared' import type { ServerRuntime } from '../../server/config-shared'
import type { NextConfig } from '../../server/config-shared' import type { NextConfig } from '../../server/config-shared'
import { tryToExtractExportedConstValue } from './extract-const-value' import { tryToExtractExportedConstValue } from './extract-const-value'
import { escapeStringRegexp } from '../../shared/lib/escape-regexp' import { escapeStringRegexp } from '../../shared/lib/escape-regexp'
...@@ -6,13 +6,14 @@ import { parseModule } from './parse-module' ...@@ -6,13 +6,14 @@ import { parseModule } from './parse-module'
import { promises as fs } from 'fs' import { promises as fs } from 'fs'
import { tryToParsePath } from '../../lib/try-to-parse-path' import { tryToParsePath } from '../../lib/try-to-parse-path'
import * as Log from '../output/log' import * as Log from '../output/log'
import { SERVER_RUNTIME } from '../../lib/constants'
interface MiddlewareConfig { interface MiddlewareConfig {
pathMatcher: RegExp pathMatcher: RegExp
} }
export interface PageStaticInfo { export interface PageStaticInfo {
runtime?: PageRuntime runtime?: ServerRuntime
ssg?: boolean ssg?: boolean
ssr?: boolean ssr?: boolean
middleware?: Partial<MiddlewareConfig> middleware?: Partial<MiddlewareConfig>
...@@ -39,15 +40,15 @@ export async function getPageStaticInfo(params: { ...@@ -39,15 +40,15 @@ export async function getPageStaticInfo(params: {
const { ssg, ssr } = checkExports(swcAST) const { ssg, ssr } = checkExports(swcAST)
const config = tryToExtractExportedConstValue(swcAST, 'config') || {} const config = tryToExtractExportedConstValue(swcAST, 'config') || {}
let runtime = ['experimental-edge', 'edge'].includes(config?.runtime) let runtime =
? 'edge' SERVER_RUNTIME.edge === config?.runtime
: ssr || ssg ? SERVER_RUNTIME.edge
? config?.runtime || nextConfig.experimental?.runtime : ssr || ssg
: undefined ? config?.runtime || nextConfig.experimental?.runtime
: undefined
if (runtime === 'experimental-edge' || runtime === 'edge') { if (runtime === SERVER_RUNTIME.edge) {
warnAboutExperimentalEdgeApiFunctions() warnAboutExperimentalEdgeApiFunctions()
runtime = 'edge'
} }
const middlewareConfig = getMiddlewareConfig(config, nextConfig) const middlewareConfig = getMiddlewareConfig(config, nextConfig)
......
...@@ -2,7 +2,7 @@ import type { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pag ...@@ -2,7 +2,7 @@ import type { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pag
import type { MiddlewareLoaderOptions } from './webpack/loaders/next-middleware-loader' import type { MiddlewareLoaderOptions } from './webpack/loaders/next-middleware-loader'
import type { EdgeSSRLoaderQuery } from './webpack/loaders/next-edge-ssr-loader' import type { EdgeSSRLoaderQuery } from './webpack/loaders/next-edge-ssr-loader'
import type { NextConfigComplete } from '../server/config-shared' import type { NextConfigComplete } from '../server/config-shared'
import type { PageRuntime } from '../server/config-shared' import type { ServerRuntime } from '../server/config-shared'
import type { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader' import type { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader'
import type { webpack5 } from 'next/dist/compiled/webpack/webpack' import type { webpack5 } from 'next/dist/compiled/webpack/webpack'
import type { LoadedEnvFiles } from '@next/env' import type { LoadedEnvFiles } from '@next/env'
...@@ -15,6 +15,7 @@ import { ...@@ -15,6 +15,7 @@ import {
PAGES_DIR_ALIAS, PAGES_DIR_ALIAS,
ROOT_DIR_ALIAS, ROOT_DIR_ALIAS,
APP_DIR_ALIAS, APP_DIR_ALIAS,
SERVER_RUNTIME,
} from '../lib/constants' } from '../lib/constants'
import { import {
CLIENT_STATIC_FILES_RUNTIME_AMP, CLIENT_STATIC_FILES_RUNTIME_AMP,
...@@ -439,12 +440,12 @@ export function runDependingOnPageType<T>(params: { ...@@ -439,12 +440,12 @@ export function runDependingOnPageType<T>(params: {
onEdgeServer: () => T onEdgeServer: () => T
onServer: () => T onServer: () => T
page: string page: string
pageRuntime: PageRuntime pageRuntime: ServerRuntime
}) { }) {
if (isMiddlewareFile(params.page)) { if (isMiddlewareFile(params.page)) {
return { edgeServer: params.onEdgeServer() } return { edgeServer: params.onEdgeServer() }
} else if (params.page.match(API_ROUTE)) { } else if (params.page.match(API_ROUTE)) {
return params.pageRuntime === 'edge' return params.pageRuntime === SERVER_RUNTIME.edge
? { edgeServer: params.onEdgeServer() } ? { edgeServer: params.onEdgeServer() }
: { server: params.onServer() } : { server: params.onServer() }
} else if (params.page === '/_document') { } else if (params.page === '/_document') {
...@@ -457,7 +458,7 @@ export function runDependingOnPageType<T>(params: { ...@@ -457,7 +458,7 @@ export function runDependingOnPageType<T>(params: {
) { ) {
return { client: params.onClient(), server: params.onServer() } return { client: params.onClient(), server: params.onServer() }
} else { } else {
return params.pageRuntime === 'edge' return params.pageRuntime === SERVER_RUNTIME.edge
? { client: params.onClient(), edgeServer: params.onEdgeServer() } ? { client: params.onClient(), edgeServer: params.onEdgeServer() }
: { client: params.onClient(), server: params.onServer() } : { client: params.onClient(), server: params.onServer() }
} }
......
...@@ -18,6 +18,7 @@ import { ...@@ -18,6 +18,7 @@ import {
PUBLIC_DIR_MIDDLEWARE_CONFLICT, PUBLIC_DIR_MIDDLEWARE_CONFLICT,
MIDDLEWARE_FILENAME, MIDDLEWARE_FILENAME,
PAGES_DIR_ALIAS, PAGES_DIR_ALIAS,
SERVER_RUNTIME,
} from '../lib/constants' } from '../lib/constants'
import { fileExists } from '../lib/file-exists' import { fileExists } from '../lib/file-exists'
import { findPagesDir } from '../lib/find-pages-dir' import { findPagesDir } from '../lib/find-pages-dir'
...@@ -1117,7 +1118,7 @@ export default async function build( ...@@ -1117,7 +1118,7 @@ export default async function build(
if ( if (
!isReservedPage(page) && !isReservedPage(page) &&
// We currently don't support static optimization in the Edge runtime. // We currently don't support static optimization in the Edge runtime.
pageRuntime !== 'edge' pageRuntime !== SERVER_RUNTIME.edge
) { ) {
try { try {
let isPageStaticSpan = let isPageStaticSpan =
......
import type { import type {
NextConfig, NextConfig,
NextConfigComplete, NextConfigComplete,
PageRuntime, ServerRuntime,
} from '../server/config-shared' } from '../server/config-shared'
import type { webpack5 } from 'next/dist/compiled/webpack/webpack' import type { webpack5 } from 'next/dist/compiled/webpack/webpack'
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
SERVER_PROPS_GET_INIT_PROPS_CONFLICT, SERVER_PROPS_GET_INIT_PROPS_CONFLICT,
SERVER_PROPS_SSG_CONFLICT, SERVER_PROPS_SSG_CONFLICT,
MIDDLEWARE_FILENAME, MIDDLEWARE_FILENAME,
SERVER_RUNTIME,
} from '../lib/constants' } from '../lib/constants'
import { EDGE_RUNTIME_WEBPACK } from '../shared/lib/constants' import { EDGE_RUNTIME_WEBPACK } from '../shared/lib/constants'
import prettyBytes from '../lib/pretty-bytes' import prettyBytes from '../lib/pretty-bytes'
...@@ -76,7 +77,7 @@ export interface PageInfo { ...@@ -76,7 +77,7 @@ export interface PageInfo {
initialRevalidateSeconds: number | false initialRevalidateSeconds: number | false
pageDuration: number | undefined pageDuration: number | undefined
ssgPageDurations: number[] | undefined ssgPageDurations: number[] | undefined
runtime: PageRuntime runtime: ServerRuntime
} }
export async function printTreeView( export async function printTreeView(
...@@ -193,7 +194,7 @@ export async function printTreeView( ...@@ -193,7 +194,7 @@ export async function printTreeView(
? '○' ? '○'
: pageInfo?.isSsg : pageInfo?.isSsg
? '●' ? '●'
: pageInfo?.runtime === 'edge' : pageInfo?.runtime === SERVER_RUNTIME.edge
? 'ℇ' ? 'ℇ'
: 'λ' : 'λ'
...@@ -1295,7 +1296,7 @@ export async function isEdgeRuntimeCompiled( ...@@ -1295,7 +1296,7 @@ export async function isEdgeRuntimeCompiled(
// Check the page runtime as well since we cannot detect the runtime from // Check the page runtime as well since we cannot detect the runtime from
// compilation when it's for the client part of edge function // compilation when it's for the client part of edge function
return staticInfo.runtime === 'edge' return staticInfo.runtime === SERVER_RUNTIME.edge
} }
export function getNodeBuiltinModuleNotSupportedInEdgeRuntimeMessage( export function getNodeBuiltinModuleNotSupportedInEdgeRuntimeMessage(
......
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
PAGES_DIR_ALIAS, PAGES_DIR_ALIAS,
ROOT_DIR_ALIAS, ROOT_DIR_ALIAS,
APP_DIR_ALIAS, APP_DIR_ALIAS,
SERVER_RUNTIME,
} from '../lib/constants' } from '../lib/constants'
import { fileExists } from '../lib/file-exists' import { fileExists } from '../lib/file-exists'
import { CustomRoutes } from '../lib/load-custom-routes.js' import { CustomRoutes } from '../lib/load-custom-routes.js'
...@@ -385,7 +386,7 @@ export default async function getBaseWebpackConfig( ...@@ -385,7 +386,7 @@ export default async function getBaseWebpackConfig(
: config.experimental.disableOptimizedLoading : config.experimental.disableOptimizedLoading
if (isClient) { if (isClient) {
if (config.experimental.runtime === 'edge') { if (config.experimental.runtime === SERVER_RUNTIME.edge) {
Log.warn( Log.warn(
'You are using the experimental Edge Runtime with `experimental.runtime`.' 'You are using the experimental Edge Runtime with `experimental.runtime`.'
) )
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
WebNextRequest, WebNextRequest,
WebNextResponse, WebNextResponse,
} from '../../../../server/base-http/web' } from '../../../../server/base-http/web'
import { SERVER_RUNTIME } from '../../../../lib/constants'
export function getRender({ export function getRender({
dev, dev,
...@@ -55,7 +56,7 @@ export function getRender({ ...@@ -55,7 +56,7 @@ export function getRender({
page, page,
extendRenderOpts: { extendRenderOpts: {
buildId, buildId,
runtime: 'edge', runtime: SERVER_RUNTIME.edge,
supportsDynamicHTML: true, supportsDynamicHTML: true,
disableOptimizedLoading: true, disableOptimizedLoading: true,
serverComponentManifest, serverComponentManifest,
......
import { SERVER_RUNTIME } from '../../../lib/constants'
export default async function transformSource(this: any): Promise<string> { export default async function transformSource(this: any): Promise<string> {
let { modules, runtime, ssr } = this.getOptions() let { modules, runtime, ssr } = this.getOptions()
if (!Array.isArray(modules)) { if (!Array.isArray(modules)) {
...@@ -18,7 +20,7 @@ export default async function transformSource(this: any): Promise<string> { ...@@ -18,7 +20,7 @@ export default async function transformSource(this: any): Promise<string> {
export default function RSC() {}; export default function RSC() {};
` + ` +
// Currently for the Edge runtime, we treat all RSC pages as SSR pages. // Currently for the Edge runtime, we treat all RSC pages as SSR pages.
(runtime === 'edge' (runtime === SERVER_RUNTIME.edge
? 'export const __N_SSP = true;' ? 'export const __N_SSP = true;'
: ssr : ssr
? `export const __N_SSP = true;` ? `export const __N_SSP = true;`
......
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
entries, entries,
} from '../../../server/dev/on-demand-entry-handler' } from '../../../server/dev/on-demand-entry-handler'
import { getPageStaticInfo } from '../../analysis/get-page-static-info' import { getPageStaticInfo } from '../../analysis/get-page-static-info'
import { SERVER_RUNTIME } from '../../../lib/constants'
type Options = { type Options = {
dev: boolean dev: boolean
...@@ -111,7 +112,9 @@ export class ClientEntryPlugin { ...@@ -111,7 +112,9 @@ export class ClientEntryPlugin {
const clientLoader = `next-flight-client-entry-loader?${stringify({ const clientLoader = `next-flight-client-entry-loader?${stringify({
modules: clientComponentImports, modules: clientComponentImports,
runtime: this.isEdgeServer ? 'edge' : 'nodejs', runtime: this.isEdgeServer
? SERVER_RUNTIME.edge
: SERVER_RUNTIME.nodejs,
ssr: pageStaticInfo.ssr, ssr: pageStaticInfo.ssr,
// Adding name here to make the entry key unique. // Adding name here to make the entry key unique.
name, name,
......
import type { ServerRuntime } from '../server/config-shared'
import { join } from '../shared/lib/isomorphic/path' import { join } from '../shared/lib/isomorphic/path'
export const NEXT_PROJECT_ROOT = join(__dirname, '..', '..') export const NEXT_PROJECT_ROOT = join(__dirname, '..', '..')
...@@ -84,3 +85,8 @@ export const ESLINT_PROMPT_VALUES = [ ...@@ -84,3 +85,8 @@ export const ESLINT_PROMPT_VALUES = [
config: null, config: null,
}, },
] ]
export const SERVER_RUNTIME: Record<string, ServerRuntime> = {
edge: 'experimental-edge',
nodejs: 'nodejs',
}
import type { IncomingMessage, ServerResponse } from 'http' import type { IncomingMessage, ServerResponse } from 'http'
import type { LoadComponentsReturnType } from './load-components' import type { LoadComponentsReturnType } from './load-components'
import type { ServerRuntime } from './config-shared'
import React from 'react' import React from 'react'
import { ParsedUrlQuery, stringify as stringifyQuery } from 'querystring' import { ParsedUrlQuery, stringify as stringifyQuery } from 'querystring'
...@@ -30,7 +31,7 @@ export type RenderOptsPartial = { ...@@ -30,7 +31,7 @@ export type RenderOptsPartial = {
dev?: boolean dev?: boolean
serverComponentManifest?: any serverComponentManifest?: any
supportsDynamicHTML?: boolean supportsDynamicHTML?: boolean
runtime?: 'nodejs' | 'edge' runtime?: ServerRuntime
serverComponents?: boolean serverComponents?: boolean
} }
......
...@@ -6,7 +6,11 @@ import type { FontManifest } from './font-utils' ...@@ -6,7 +6,11 @@ import type { FontManifest } from './font-utils'
import type { LoadComponentsReturnType } from './load-components' import type { LoadComponentsReturnType } from './load-components'
import type { RouteMatch } from '../shared/lib/router/utils/route-matcher' import type { RouteMatch } from '../shared/lib/router/utils/route-matcher'
import type { Params } from '../shared/lib/router/utils/route-matcher' import type { Params } from '../shared/lib/router/utils/route-matcher'
import type { NextConfig, NextConfigComplete } from './config-shared' import type {
NextConfig,
NextConfigComplete,
ServerRuntime,
} from './config-shared'
import type { NextParsedUrlQuery, NextUrlWithParsedQuery } from './request-meta' import type { NextParsedUrlQuery, NextUrlWithParsedQuery } from './request-meta'
import type { ParsedUrlQuery } from 'querystring' import type { ParsedUrlQuery } from 'querystring'
import type { RenderOpts, RenderOptsPartial } from './render' import type { RenderOpts, RenderOptsPartial } from './render'
...@@ -172,7 +176,7 @@ export default abstract class Server<ServerOptions extends Options = Options> { ...@@ -172,7 +176,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
defaultLocale?: string defaultLocale?: string
domainLocales?: DomainLocale[] domainLocales?: DomainLocale[]
distDir: string distDir: string
runtime?: 'nodejs' | 'edge' runtime?: ServerRuntime
serverComponents?: boolean serverComponents?: boolean
crossOrigin?: string crossOrigin?: string
supportsDynamicHTML?: boolean supportsDynamicHTML?: boolean
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
RemotePattern, RemotePattern,
} from '../shared/lib/image-config' } from '../shared/lib/image-config'
export type PageRuntime = 'nodejs' | 'edge' | undefined export type ServerRuntime = 'nodejs' | 'experimental-edge' | undefined
export type NextConfigComplete = Required<NextConfig> & { export type NextConfigComplete = Required<NextConfig> & {
images: Required<ImageConfigComplete> images: Required<ImageConfigComplete>
...@@ -112,7 +112,7 @@ export interface ExperimentalConfig { ...@@ -112,7 +112,7 @@ export interface ExperimentalConfig {
craCompat?: boolean craCompat?: boolean
esmExternals?: boolean | 'loose' esmExternals?: boolean | 'loose'
isrMemoryCacheSize?: number isrMemoryCacheSize?: number
runtime?: Exclude<PageRuntime, undefined> runtime?: Exclude<ServerRuntime, undefined>
serverComponents?: boolean serverComponents?: boolean
fullySpecified?: boolean fullySpecified?: boolean
urlImports?: NonNullable<webpack5.Configuration['experiments']>['buildHttp'] urlImports?: NonNullable<webpack5.Configuration['experiments']>['buildHttp']
......
...@@ -21,6 +21,7 @@ import type { LoadComponentsReturnType, ManifestItem } from './load-components' ...@@ -21,6 +21,7 @@ import type { LoadComponentsReturnType, ManifestItem } from './load-components'
import type { GetServerSideProps, GetStaticProps, PreviewData } from '../types' import type { GetServerSideProps, GetStaticProps, PreviewData } from '../types'
import type { UnwrapPromise } from '../lib/coalesced-function' import type { UnwrapPromise } from '../lib/coalesced-function'
import type { ReactReadableStream } from './node-web-streams-helper' import type { ReactReadableStream } from './node-web-streams-helper'
import type { ServerRuntime } from './config-shared'
import React from 'react' import React from 'react'
import { createFromReadableStream } from 'next/dist/compiled/react-server-dom-webpack' import { createFromReadableStream } from 'next/dist/compiled/react-server-dom-webpack'
...@@ -238,7 +239,7 @@ export type RenderOptsPartial = { ...@@ -238,7 +239,7 @@ export type RenderOptsPartial = {
domainLocales?: DomainLocale[] domainLocales?: DomainLocale[]
disableOptimizedLoading?: boolean disableOptimizedLoading?: boolean
supportsDynamicHTML?: boolean supportsDynamicHTML?: boolean
runtime?: 'nodejs' | 'edge' runtime?: ServerRuntime
serverComponents?: boolean serverComponents?: boolean
customServer?: boolean customServer?: boolean
crossOrigin?: string crossOrigin?: string
......
...@@ -138,7 +138,7 @@ export default class NextWebServer extends BaseServer<WebServerOptions> { ...@@ -138,7 +138,7 @@ export default class NextWebServer extends BaseServer<WebServerOptions> {
{ {
...renderOpts, ...renderOpts,
disableOptimizedLoading: true, disableOptimizedLoading: true,
runtime: 'edge', runtime: 'experimental-edge',
} }
) )
} }
......
import type { BuildManifest } from '../../server/get-page-files' import type { BuildManifest } from '../../server/get-page-files'
import type { ServerRuntime } from '../../server/config-shared'
import type { NEXT_DATA } from './utils' import type { NEXT_DATA } from './utils'
import { createContext } from 'react' import { createContext } from 'react'
...@@ -37,7 +38,7 @@ export type HtmlProps = { ...@@ -37,7 +38,7 @@ export type HtmlProps = {
optimizeCss?: boolean optimizeCss?: boolean
optimizeFonts?: boolean optimizeFonts?: boolean
nextScriptWorkers?: boolean nextScriptWorkers?: boolean
runtime?: 'edge' | 'nodejs' runtime?: ServerRuntime
hasConcurrentFeatures?: boolean hasConcurrentFeatures?: boolean
largePageDataBytes?: number largePageDataBytes?: number
} }
......
...@@ -50,7 +50,7 @@ function writeNextConfig(config, reactVersion = 17) { ...@@ -50,7 +50,7 @@ function writeNextConfig(config, reactVersion = 17) {
describe('Invalid react 18 webpack config', () => { describe('Invalid react 18 webpack config', () => {
it('should install react 18 when `experimental.runtime` is enabled', async () => { it('should install react 18 when `experimental.runtime` is enabled', async () => {
writeNextConfig({ writeNextConfig({
runtime: 'edge', runtime: 'experimental-edge',
}) })
const { stderr } = await nextBuild(appDir, [], { stderr: true, nodeArgs }) const { stderr } = await nextBuild(appDir, [], { stderr: true, nodeArgs })
nextConfig.restore() nextConfig.restore()
......
module.exports = { module.exports = {
// reactStrictMode: true, // reactStrictMode: true,
experimental: { experimental: {
// runtime: 'edge', // runtime: 'experimental-edge',
}, },
images: { images: {
deviceSizes: [480, 1024, 1600, 2000], deviceSizes: [480, 1024, 1600, 2000],
......
...@@ -22,5 +22,5 @@ export default function Index() { ...@@ -22,5 +22,5 @@ export default function Index() {
} }
export const config = { export const config = {
// runtime: 'edge' // runtime: 'experimental-edge'
} }
...@@ -67,8 +67,14 @@ function runTestsAgainstRuntime(runtime) { ...@@ -67,8 +67,14 @@ function runTestsAgainstRuntime(runtime) {
if (env === 'dev') { if (env === 'dev') {
invalidPage.write(`export const value = 1`) invalidPage.write(`export const value = 1`)
} }
nextConfig.replace("// runtime: 'edge'", `runtime: '${runtime}'`) nextConfig.replace(
indexPage.replace("// runtime: 'edge'", `runtime: '${runtime}'`) "// runtime: 'experimental-edge'",
`runtime: '${runtime}'`
)
indexPage.replace(
"// runtime: 'experimental-edge'",
`runtime: '${runtime}'`
)
}, },
afterAll: (env) => { afterAll: (env) => {
if (env === 'dev') { if (env === 'dev') {
...@@ -81,7 +87,7 @@ function runTestsAgainstRuntime(runtime) { ...@@ -81,7 +87,7 @@ function runTestsAgainstRuntime(runtime) {
) )
} }
runTestsAgainstRuntime('edge') runTestsAgainstRuntime('experimental-edge')
runTestsAgainstRuntime('nodejs') runTestsAgainstRuntime('nodejs')
function runTests(name, fn, opts) { function runTests(name, fn, opts) {
......
...@@ -6,6 +6,6 @@ module.exports = { ...@@ -6,6 +6,6 @@ module.exports = {
pageExtensions: ['js', 'ts', 'jsx'], // .tsx won't be treat as page, pageExtensions: ['js', 'ts', 'jsx'], // .tsx won't be treat as page,
experimental: { experimental: {
serverComponents: true, serverComponents: true,
runtime: 'edge', runtime: 'experimental-edge',
}, },
} }
...@@ -7,5 +7,5 @@ export default function MyError() { ...@@ -7,5 +7,5 @@ export default function MyError() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -20,5 +20,5 @@ export default function page() { ...@@ -20,5 +20,5 @@ export default function page() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -32,5 +32,5 @@ export default function Page() { ...@@ -32,5 +32,5 @@ export default function Page() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -9,5 +9,5 @@ const Page = () => { ...@@ -9,5 +9,5 @@ const Page = () => {
export default Page export default Page
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -26,8 +26,8 @@ function Data() { ...@@ -26,8 +26,8 @@ function Data() {
export default function () { export default function () {
return ( return (
<> <>
{process.version {process.env.NEXT_RUNTIME === 'edge'
? `Runtime: Node.js ${process.version}` ? `Runtime: Node.js`
: 'Runtime: Edge/Browser'} : 'Runtime: Edge/Browser'}
<br /> <br />
<div className="suspense"> <div className="suspense">
...@@ -42,5 +42,5 @@ export default function () { ...@@ -42,5 +42,5 @@ export default function () {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -31,5 +31,5 @@ export default function Page() { ...@@ -31,5 +31,5 @@ export default function Page() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -23,5 +23,5 @@ export default function Page() { ...@@ -23,5 +23,5 @@ export default function Page() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -9,5 +9,5 @@ export default function Page() { ...@@ -9,5 +9,5 @@ export default function Page() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -2,6 +2,6 @@ module.exports = { ...@@ -2,6 +2,6 @@ module.exports = {
reactStrictMode: true, reactStrictMode: true,
experimental: { experimental: {
serverComponents: true, serverComponents: true,
// runtime: 'edge', // runtime: 'experimental-edge',
}, },
} }
...@@ -3,5 +3,5 @@ export default (req) => { ...@@ -3,5 +3,5 @@ export default (req) => {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -14,5 +14,5 @@ export default function Page() { ...@@ -14,5 +14,5 @@ export default function Page() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -14,5 +14,5 @@ export default function Page() { ...@@ -14,5 +14,5 @@ export default function Page() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
export default function (context) { export default function (context) {
it("should include global styles under `runtime: 'edge'`", async () => { it("should include global styles under `runtime: 'experimental-edge'`", async () => {
const browser = await webdriver(context.appPort, '/global-styles') const browser = await webdriver(context.appPort, '/global-styles')
const currentColor = await browser.eval( const currentColor = await browser.eval(
`window.getComputedStyle(document.querySelector('#red')).color` `window.getComputedStyle(document.querySelector('#red')).color`
......
...@@ -59,7 +59,7 @@ describe('Edge runtime - errors', () => { ...@@ -59,7 +59,7 @@ describe('Edge runtime - errors', () => {
const edgeRuntimeBasicSuite = { const edgeRuntimeBasicSuite = {
runTests: (context, env) => { runTests: (context, env) => {
const options = { runtime: 'edge', env } const options = { runtime: 'experimental-edge', env }
const distDir = join(appDir, '.next') const distDir = join(appDir, '.next')
basic(context, options) basic(context, options)
streaming(context, options) streaming(context, options)
...@@ -152,7 +152,7 @@ const nodejsRuntimeBasicSuite = { ...@@ -152,7 +152,7 @@ const nodejsRuntimeBasicSuite = {
}, },
beforeAll: () => { beforeAll: () => {
error500Page.write(page500) error500Page.write(page500)
nextConfig.replace("runtime: 'edge'", "runtime: 'nodejs'") nextConfig.replace("runtime: 'experimental-edge'", "runtime: 'nodejs'")
}, },
afterAll: () => { afterAll: () => {
error500Page.delete() error500Page.delete()
......
...@@ -10,5 +10,5 @@ export default function Index() { ...@@ -10,5 +10,5 @@ export default function Index() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
} }
module.exports = { module.exports = {
trailingSlash: true, trailingSlash: true,
experimental: { experimental: {
runtime: 'edge', runtime: 'experimental-edge',
}, },
} }
...@@ -11,4 +11,4 @@ export default function Page() { ...@@ -11,4 +11,4 @@ export default function Page() {
) )
} }
export const config = { runtime: 'edge' } export const config = { runtime: 'experimental-edge' }
...@@ -11,4 +11,4 @@ export default function Page() { ...@@ -11,4 +11,4 @@ export default function Page() {
) )
} }
export const config = { runtime: 'edge' } export const config = { runtime: 'experimental-edge' }
...@@ -6,4 +6,4 @@ export default function Page() { ...@@ -6,4 +6,4 @@ export default function Page() {
) )
} }
export const config = { runtime: 'edge' } export const config = { runtime: 'experimental-edge' }
...@@ -3,6 +3,6 @@ export default function Edge() { ...@@ -3,6 +3,6 @@ export default function Edge() {
} }
export const config = { export const config = {
runtime: 'edge', runtime: 'experimental-edge',
amp: false, amp: false,
} }
...@@ -3,7 +3,7 @@ import { join } from 'path' ...@@ -3,7 +3,7 @@ import { join } from 'path'
const fixtureDir = join(__dirname, 'fixtures') const fixtureDir = join(__dirname, 'fixtures')
function createNextConfig(runtime?: 'edge' | 'nodejs') { function createNextConfig(runtime?: 'experimental-edge' | 'nodejs') {
return { return {
experimental: { runtime }, experimental: { runtime },
} }
...@@ -31,7 +31,7 @@ describe('parse page runtime config', () => { ...@@ -31,7 +31,7 @@ describe('parse page runtime config', () => {
pageFilePath: join(fixtureDir, 'page-runtime/edge.js'), pageFilePath: join(fixtureDir, 'page-runtime/edge.js'),
nextConfig: createNextConfig(), nextConfig: createNextConfig(),
}) })
expect(runtime).toBe('edge') expect(runtime).toBe('experimental-edge')
}) })
it('should return undefined if no runtime is specified', async () => { it('should return undefined if no runtime is specified', async () => {
...@@ -47,16 +47,16 @@ describe('fallback to the global runtime configuration', () => { ...@@ -47,16 +47,16 @@ describe('fallback to the global runtime configuration', () => {
it('should fallback when gSP is defined and exported', async () => { it('should fallback when gSP is defined and exported', async () => {
const { runtime } = await getPageStaticInfo({ const { runtime } = await getPageStaticInfo({
pageFilePath: join(fixtureDir, 'page-runtime/fallback-with-gsp.js'), pageFilePath: join(fixtureDir, 'page-runtime/fallback-with-gsp.js'),
nextConfig: createNextConfig('edge'), nextConfig: createNextConfig('experimental-edge'),
}) })
expect(runtime).toBe('edge') expect(runtime).toBe('experimental-edge')
}) })
it('should fallback when gSP is re-exported from other module', async () => { it('should fallback when gSP is re-exported from other module', async () => {
const { runtime } = await getPageStaticInfo({ const { runtime } = await getPageStaticInfo({
pageFilePath: join(fixtureDir, 'page-runtime/fallback-re-export-gsp.js'), pageFilePath: join(fixtureDir, 'page-runtime/fallback-re-export-gsp.js'),
nextConfig: createNextConfig('edge'), nextConfig: createNextConfig('experimental-edge'),
}) })
expect(runtime).toBe('edge') expect(runtime).toBe('experimental-edge')
}) })
}) })
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