Revert "perf: add bundled rendering runtimes (#52997)" (#55117)

This reverts commit a5b7c77c1f.

Our E2E tests are failing with this change this reverts to allow investigating async 

x-ref: https://github.com/vercel/next.js/actions/runs/6112149126/job/16589769954
This commit is contained in:
JJ Kasper 2023-09-07 14:07:53 -07:00 committed by GitHub
parent d330f7b02c
commit 7267538e00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
159 changed files with 957 additions and 1512 deletions

View file

@ -162,10 +162,7 @@
},
{
"files": ["packages/**"],
"excludedFiles": [
"packages/next/taskfile*.js",
"packages/next/webpack.config.js"
],
"excludedFiles": ["packages/next/taskfile.js"],
"rules": {
"no-shadow": ["warn", { "builtinGlobals": false }],
"import/no-extraneous-dependencies": [

View file

@ -1,5 +0,0 @@
export function GET() {
return { name: 'John Doe' }
}
export const dynamic = 'force-dynamic'

View file

@ -1,12 +0,0 @@
import React from 'react'
export default function Layout({ children }) {
return (
<html>
<head>
<title>My App</title>
</head>
<body>{children}</body>
</html>
)
}

View file

@ -1,7 +0,0 @@
import React from 'react'
export default function Page() {
return <h1>My Page</h1>
}
export const dynamic = 'force-dynamic'

View file

@ -1,5 +0,0 @@
module.exports = {
experimental: {
serverMinification: true,
},
}

View file

@ -1,3 +0,0 @@
export default function handler(req, res) {
res.status(200).json({ name: 'John Doe' })
}

View file

@ -1,7 +0,0 @@
export default () => 'Hello World'
export function getServerSideProps() {
return {
props: {},
}
}

View file

@ -2,8 +2,6 @@
// the other imports
import startOperationStreamHandler from '../internal/operation-stream'
import 'next/dist/server/node-polyfill-fetch'
import { join } from 'path'
import { parse as parseUrl } from 'node:url'

View file

@ -3,15 +3,13 @@
import startOperationStreamHandler from '../internal/operation-stream'
import '../polyfill/app-polyfills.ts'
// TODO: when actions are supported, this should be removed/changed
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = 'next'
import 'next/dist/server/require-hook'
import type { IncomingMessage } from 'node:http'
import type { RenderData } from 'types/turbopack'
import type { RenderOpts } from 'next/dist/server/app-render/types'
import { renderToHTMLOrFlight } from 'next/dist/server/app-render/app-render'
import { RSC_VARY_HEADER } from 'next/dist/client/components/app-router-headers'
import { headersFromEntries, initProxiedHeaders } from '../internal/headers'
import { parse, ParsedUrlQuery } from 'node:querystring'
@ -25,10 +23,6 @@ import { join } from 'node:path'
import { nodeFs } from 'next/dist/server/lib/node-fs-methods'
import { IncrementalCache } from 'next/dist/server/lib/incremental-cache'
const {
renderToHTMLOrFlight,
} = require('next/dist/compiled/next-server/app-page.runtime.dev')
installRequireAndChunkLoad()
const MIME_TEXT_HTML_UTF8 = 'text/html; charset=utf-8'

View file

@ -6,7 +6,7 @@ import { createFromReadableStream } from 'next/dist/compiled/react-server-dom-we
import { callServer } from 'next/dist/client/app-call-server'
import { linkGc } from 'next/dist/client/app-link-gc'
import { HeadManagerContext } from 'next/dist/shared/lib/head-manager-context.shared-runtime'
import { HeadManagerContext } from 'next/dist/shared/lib/head-manager-context'
import { initializeHMR } from '@vercel/turbopack-next/dev/client'

View file

@ -3,12 +3,11 @@
import { IPC } from '@vercel/turbopack-node/ipc/index'
import 'next/dist/server/node-polyfill-fetch.js'
import 'next/dist/server/require-hook'
import './shims'
import type { IncomingMessage, ServerResponse } from 'node:http'
import type { RenderOpts } from 'next/dist/server/render'
import { renderToHTML, RenderOpts } from 'next/dist/server/render'
import { getRedirectStatus } from 'next/dist/lib/redirect-status'
import { PERMANENT_REDIRECT_STATUS } from 'next/dist/shared/lib/constants'
import { buildStaticPaths } from 'next/dist/build/utils'
@ -22,9 +21,6 @@ import type { RenderData } from 'types/turbopack'
import type { ChunkGroup } from 'types/next'
import type { NextComponentType } from 'next/types'
import { parse } from 'node:querystring'
const {
renderToHTML,
} = require('next/dist/compiled/next-server/pages.runtime.dev')
const ipc = IPC as Ipc<IpcIncomingMessage, IpcOutgoingMessage>

View file

@ -2,7 +2,7 @@ use std::{collections::HashMap, io::Write as _, iter::once};
use anyhow::{bail, Result};
use indexmap::indexmap;
use indoc::formatdoc;
use indoc::indoc;
use serde_json::Value as JsonValue;
use turbo_tasks::Vc;
use turbopack_binding::{
@ -964,18 +964,13 @@ impl AppRenderer {
.emit();
}
let mut result = RopeBuilder::from(
formatdoc!(
"
\"TURBOPACK {{ chunking-type: isolatedParallel; transition: {rsc_transition} }}\";
let mut result = RopeBuilder::from(indoc! {"
\"TURBOPACK { chunking-type: isolatedParallel; transition: next-edge-server-component }\";
import GlobalErrorMod from \"next/dist/client/components/error-boundary\"
const {{ GlobalError }} = GlobalErrorMod;
\"TURBOPACK {{ chunking-type: isolatedParallel; transition: {rsc_transition} }}\";
const { GlobalError } = GlobalErrorMod;
\"TURBOPACK { chunking-type: isolatedParallel; transition: next-edge-server-component }\";
import base from \"next/dist/server/app-render/entry-base\"\n
"
)
.into_bytes(),
);
"});
for import in loader_tree_module.imports {
writeln!(result, "{import}")?;

View file

@ -96,9 +96,10 @@ pub async fn get_edge_resolve_options_context(
];
match ty {
ServerContextType::AppRSC { .. } => custom_conditions.push("react-server".to_string()),
ServerContextType::AppRoute { .. }
| ServerContextType::Pages { .. }
ServerContextType::AppRSC { .. } | ServerContextType::AppRoute { .. } => {
custom_conditions.push("react-server".to_string())
}
ServerContextType::Pages { .. }
| ServerContextType::PagesData { .. }
| ServerContextType::AppSSR { .. }
| ServerContextType::Middleware { .. } => {}

View file

@ -58,26 +58,24 @@ impl Transition for NextEdgeRouteTransition {
#[turbo_tasks::function]
async fn process_module(
self: Vc<Self>,
&self,
asset: Vc<Box<dyn Module>>,
context: Vc<ModuleAssetContext>,
) -> Result<Vc<Box<dyn Module>>> {
let new_context = self.process_context(context);
let this = self.await?;
let new_asset = route_bootstrap(
asset,
Vc::upcast(new_context),
this.base_path,
this.bootstrap_asset,
Vc::upcast(context),
self.base_path,
self.bootstrap_asset,
Vc::cell(indexmap! {
"NAME".to_string() => this.entry_name.clone(),
"NAME".to_string() => self.entry_name.clone(),
}),
);
let asset = ChunkGroupFilesAsset {
module: Vc::upcast(new_asset),
client_root: this.output_path,
chunking_context: this.edge_chunking_context,
client_root: self.output_path,
chunking_context: self.edge_chunking_context,
runtime_entries: None,
};

View file

@ -216,26 +216,25 @@ pub async fn get_next_server_import_map(
let ty = ty.into_value();
insert_next_server_special_aliases(&mut import_map, ty, mode, NextRuntime::NodeJs).await?;
let external: Vc<ImportMapping> = ImportMapping::External(None).cell();
let external = ImportMapping::External(None).cell();
import_map.insert_exact_alias("next/dist/server/require-hook", external);
match ty {
ServerContextType::Pages { .. } | ServerContextType::PagesData { .. } => {
import_map.insert_exact_alias("next", external);
import_map.insert_wildcard_alias("next/", external);
import_map.insert_exact_alias("react", external);
import_map.insert_wildcard_alias("react/", external);
import_map.insert_exact_alias("react-dom", external);
import_map.insert_wildcard_alias("react-dom/", external);
import_map.insert_exact_alias("styled-jsx", external);
import_map.insert_wildcard_alias("styled-jsx/", external);
import_map.insert_wildcard_alias("react-server-dom-webpack/", external);
// TODO: we should not bundle next/dist/build/utils in the pages renderer at all
import_map.insert_wildcard_alias("next/dist/build/utils", external);
import_map.insert_exact_alias("react-server-dom-webpack/", external);
}
ServerContextType::AppSSR { .. }
| ServerContextType::AppRSC { .. }
| ServerContextType::AppRoute { .. } => {
match mode {
NextMode::Build => {
NextMode::Development | NextMode::Build => {
import_map.insert_wildcard_alias("next/dist/server/", external);
import_map.insert_wildcard_alias("next/dist/shared/", external);
}
@ -243,7 +242,6 @@ pub async fn get_next_server_import_map(
// The sandbox can't be bundled and needs to be external
import_map.insert_exact_alias("next/dist/server/web/sandbox", external);
}
NextMode::Development => {}
}
import_map.insert_exact_alias(
"next/head",
@ -379,11 +377,6 @@ async fn insert_next_server_special_aliases(
NextRuntime::Edge => request_to_import_mapping(context_dir, request),
NextRuntime::NodeJs => external_request_to_import_mapping(request),
};
let passthrough_external_if_node =
move |context_dir: Vc<FileSystemPath>, request: &str| match runtime {
NextRuntime::Edge => request_to_import_mapping(context_dir, request),
NextRuntime::NodeJs => ImportMapping::External(None).cell(),
};
match (mode, ty) {
(_, ServerContextType::Pages { pages_dir }) => {
import_map.insert_exact_alias(
@ -420,7 +413,12 @@ async fn insert_next_server_special_aliases(
(_, ServerContextType::PagesData { .. }) => {}
// In development, we *always* use the bundled version of React, even in
// SSR, since we're bundling Next.js alongside it.
(NextMode::DevServer, ServerContextType::AppSSR { app_dir }) => {
(
NextMode::DevServer,
ServerContextType::AppSSR { app_dir }
| ServerContextType::AppRSC { app_dir, .. }
| ServerContextType::AppRoute { app_dir },
) => {
import_map.insert_exact_alias(
"@opentelemetry/api",
// TODO(WEB-625) this actually need to prefer the local version of
@ -429,40 +427,28 @@ async fn insert_next_server_special_aliases(
);
import_map.insert_exact_alias(
"react",
passthrough_external_if_node(app_dir, "next/dist/compiled/react"),
request_to_import_mapping(app_dir, "next/dist/compiled/react"),
);
import_map.insert_wildcard_alias(
"react/",
passthrough_external_if_node(app_dir, "next/dist/compiled/react/*"),
request_to_import_mapping(app_dir, "next/dist/compiled/react/*"),
);
import_map.insert_exact_alias(
"react-dom",
passthrough_external_if_node(
request_to_import_mapping(
app_dir,
"next/dist/compiled/react-dom/server-rendering-stub.js",
),
);
import_map.insert_wildcard_alias(
"react-dom/",
passthrough_external_if_node(app_dir, "next/dist/compiled/react-dom/*"),
);
import_map.insert_exact_alias(
"styled-jsx",
passthrough_external_if_node(app_dir, "next/dist/compiled/styled-jsx"),
);
import_map.insert_wildcard_alias(
"styled-jsx/",
passthrough_external_if_node(app_dir, "next/dist/compiled/styled-jsx/*"),
request_to_import_mapping(app_dir, "next/dist/compiled/react-dom/*"),
);
import_map.insert_wildcard_alias(
"react-server-dom-webpack/",
passthrough_external_if_node(
app_dir,
"next/dist/compiled/react-server-dom-webpack/*",
),
request_to_import_mapping(app_dir, "next/dist/compiled/react-server-dom-webpack/*"),
);
}
// NOTE(alexkirsz) This logic maps loosely to
// `next.js/packages/next/src/build/webpack-config.ts`, where:
//
@ -474,7 +460,7 @@ async fn insert_next_server_special_aliases(
// * passes through (react|react-dom|react-server-dom-webpack)/(.*) to
// next/dist/compiled/$1/$2
(
NextMode::Build | NextMode::Development | NextMode::DevServer,
NextMode::Build | NextMode::Development,
ServerContextType::AppRSC { app_dir, .. } | ServerContextType::AppRoute { app_dir },
) => {
import_map.insert_exact_alias(
@ -483,20 +469,10 @@ async fn insert_next_server_special_aliases(
// @opentelemetry/api
request_to_import_mapping(app_dir, "next/dist/compiled/@opentelemetry/api"),
);
if matches!(ty, ServerContextType::AppRSC { .. }) {
import_map.insert_exact_alias(
"react",
request_to_import_mapping(
app_dir,
"next/dist/compiled/react/react.shared-subset",
),
request_to_import_mapping(app_dir, "next/dist/compiled/react/react.shared-subset"),
);
} else {
import_map.insert_exact_alias(
"react",
request_to_import_mapping(app_dir, "next/dist/compiled/react"),
);
}
import_map.insert_exact_alias(
"react-dom",
request_to_import_mapping(

View file

@ -46,10 +46,7 @@ use crate::{
next_import_map::{get_next_server_import_map, mdx_import_source_file},
next_server::resolve::ExternalPredicate,
next_shared::{
resolve::{
ModuleFeatureReportResolvePlugin, NextExternalResolvePlugin,
UnsupportedModulesResolvePlugin,
},
resolve::{ModuleFeatureReportResolvePlugin, UnsupportedModulesResolvePlugin},
transforms::{
emotion::get_emotion_transform_plugin, get_relay_transform_plugin,
styled_components::get_styled_components_transform_plugin,
@ -111,9 +108,10 @@ pub async fn get_server_resolve_options_context(
let mut custom_conditions = vec![mode.node_env().to_string(), "node".to_string()];
match ty {
ServerContextType::AppRSC { .. } => custom_conditions.push("react-server".to_string()),
ServerContextType::AppRoute { .. }
| ServerContextType::Pages { .. }
ServerContextType::AppRSC { .. } | ServerContextType::AppRoute { .. } => {
custom_conditions.push("react-server".to_string())
}
ServerContextType::Pages { .. }
| ServerContextType::PagesData { .. }
| ServerContextType::AppSSR { .. }
| ServerContextType::Middleware { .. } => {}
@ -123,15 +121,12 @@ pub async fn get_server_resolve_options_context(
ExternalPredicate::AllExcept(next_config.transpile_packages()).cell(),
);
let next_external_plugin = NextExternalResolvePlugin::new(project_path);
let plugins = match ty {
ServerContextType::Pages { .. } | ServerContextType::PagesData { .. } => {
vec![
Vc::upcast(module_feature_report_resolve_plugin),
Vc::upcast(external_cjs_modules_plugin),
Vc::upcast(unsupported_modules_resolve_plugin),
Vc::upcast(next_external_plugin),
]
}
ServerContextType::AppSSR { .. }
@ -142,7 +137,6 @@ pub async fn get_server_resolve_options_context(
Vc::upcast(module_feature_report_resolve_plugin),
Vc::upcast(server_component_externals_plugin),
Vc::upcast(unsupported_modules_resolve_plugin),
Vc::upcast(next_external_plugin),
]
}
};

View file

@ -13,7 +13,7 @@ use turbopack_binding::{
parse::Request,
pattern::Pattern,
plugin::{ResolvePlugin, ResolvePluginCondition},
ResolveResult, ResolveResultItem, ResolveResultOption,
ResolveResultOption,
},
},
};
@ -102,55 +102,6 @@ impl ResolvePlugin for UnsupportedModulesResolvePlugin {
}
}
#[turbo_tasks::value]
pub(crate) struct NextExternalResolvePlugin {
root: Vc<FileSystemPath>,
}
#[turbo_tasks::value_impl]
impl NextExternalResolvePlugin {
#[turbo_tasks::function]
pub fn new(root: Vc<FileSystemPath>) -> Vc<Self> {
NextExternalResolvePlugin { root }.cell()
}
}
#[turbo_tasks::value_impl]
impl ResolvePlugin for NextExternalResolvePlugin {
#[turbo_tasks::function]
fn after_resolve_condition(&self) -> Vc<ResolvePluginCondition> {
ResolvePluginCondition::new(
self.root.root(),
Glob::new(
"**/next/dist/**/*.{external,shared-runtime,runtime.dev,runtime.prod}.js"
.to_string(),
),
)
}
#[turbo_tasks::function]
async fn after_resolve(
&self,
fs_path: Vc<FileSystemPath>,
_context: Vc<FileSystemPath>,
_request: Vc<Request>,
) -> Result<Vc<ResolveResultOption>> {
let raw_fs_path = &*fs_path.await?;
let path = raw_fs_path.path.to_string();
// Find the starting index of 'next/dist' and slice from that point. It should
// always be found since the glob pattern above is specific enough.
let starting_index = path.find("next/dist").unwrap();
// Replace '/esm/' with '/' to match the CJS version of the file.
let modified_path = &path[starting_index..].replace("/esm/", "/");
Ok(Vc::cell(Some(
ResolveResult::primary(ResolveResultItem::OriginalReferenceTypeExternal(
modified_path.to_string(),
))
.into(),
)))
}
}
/// A resolver plugin tracks the usage of certain import paths, emit
/// telemetry events if there is a match.
#[turbo_tasks::value]

View file

@ -1,17 +0,0 @@
warning - [parse] [project]/packages/next/dist/server/web/sandbox/context.js /packages/next/dist/server/web/sandbox/context.js:64:56 lint TP1004 fs.readFile(???*0*) is very dynamic
60 | }
61 | async function loadWasm(wasm) {
62 | const modules = {};
63 | await Promise.all(wasm.map(async (binding)=>{
+ v
64 + const module1 = await WebAssembly.compile(await _fs.promises.readFile(binding.filePath));
+ ^
65 | modules[binding.name] = module1;
66 | }));
67 | return modules;
68 | }
- *0* ???*1*["filePath"]
⚠️ unknown object
- *1* binding
⚠️ pattern without value

View file

@ -1,15 +0,0 @@
warning - [parse] [project]/packages/next/dist/server/web/sandbox/context.js /packages/next/dist/server/web/sandbox/context.js:355:28 lint TP1004 fs.readFileSync(???*0*, "utf-8") is very dynamic
351 | }
352 | const moduleContext = lazyModuleContext;
353 | const evaluateInContext = (filepath)=>{
354 | if (!moduleContext.paths.has(filepath)) {
+ v
355 + const content = (0, _fs.readFileSync)(filepath, "utf-8");
+ ^
356 | try {
357 | (0, _vm.runInContext)(content, moduleContext.runtime.context, {
358 | filename: filepath
359 | });
- *0* filepath
⚠️ pattern without value

View file

@ -1,47 +0,0 @@
error - [rendering] [root of the server]/invalid Error during SSR Rendering
Error: Invalid src prop (https://image-optimization-test.vercel.app/test.webp) on `next/image`, hostname "image-optimization-test.vercel.app" is not configured under images in your `next.config.js`
Debug info:
- Error: Invalid src prop (https://image-optimization-test.vercel.app/test.webp) on `next/image`, hostname "image-optimization-test.vercel.app" is not configured under images in your `next.config.js`
See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host
at defaultLoader (packages/next/dist/shared/lib/image-loader.js:41:27)
37 | process.env.NEXT_RUNTIME !== "edge") {
38 | // We use dynamic require because this should only error in development
39 | const { hasMatch } = require("./match-remote-pattern");
40 | if (!hasMatch(config.domains, config.remotePatterns, parsedSrc)) {
| v
41 + throw new Error("Invalid src prop (" + src + ') on `next/image`, hostname "' + parsedSrc.hostname + '" i...xt.config.js`\n' + "See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host");
| ^
42 | }
43 | }
44 | }
45 | }
at <unknown> (packages/next/dist/shared/lib/get-img-props.js:101:36)
97 | const { widths , kind } = getWidths(config, width, sizes);
98 | const last = widths.length - 1;
99 | return {
100 | sizes: !sizes && kind === "w" ? "100vw" : sizes,
| v
101 + srcSet: widths.map((w, i)=>loader({
| ^
102 | config,
103 | src,
104 | quality,
105 | width: w
at generateImgAttrs (packages/next/dist/shared/lib/get-img-props.js:101:24)
97 | const { widths , kind } = getWidths(config, width, sizes);
98 | const last = widths.length - 1;
99 | return {
100 | sizes: !sizes && kind === "w" ? "100vw" : sizes,
| v
101 + srcSet: widths.map((w, i)=>loader({
| ^
102 | config,
103 | src,
104 | quality,
105 | width: w
at getImgProps (packages/next/dist/shared/lib/get-img-props.js:392:27)
at <unknown> (packages/next/dist/client/image-component.js:275:82)

View file

@ -0,0 +1,6 @@
error - [rendering] [root of the server]/invalid Error during SSR Rendering
Error: Invalid src prop (https://image-optimization-test.vercel.app/test.webp) on `next/image`, hostname "image-optimization-test.vercel.app" is not configured under images in your `next.config.js`
Debug info:
- Error: Invalid src prop (https://image-optimization-test.vercel.app/test.webp) on `next/image`, hostname "image-optimization-test.vercel.app" is not configured under images in your `next.config.js`
See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host

View file

@ -120,7 +120,7 @@ function runTests() {
expect(json).toMatchObject({
edgeThenNode: 'node',
nodeThenEdge: 'node',
reactServer: 'default',
reactServer: 'react-server',
})
})
@ -129,7 +129,7 @@ function runTests() {
expect(json).toMatchObject({
edgeThenNode: 'edge',
nodeThenEdge: 'edge',
reactServer: 'default',
reactServer: 'react-server',
})
})

View file

@ -0,0 +1,13 @@
error - [resolve] [project]/packages/next/dist/compiled/nanoid/index.cjs /packages/next/dist/compiled/nanoid/index.cjs:1:45 Error resolving commonjs request
+ v---------------v
1 + (()=>{var e={113:e=>{"use strict";e.exports=require("crypto")},660:(e,r,t)=>{let l=t(113);let{urlAlphabet:a}=t(591);const n=128;let _,u;let fillPool=e=>{if(!_||...ndefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(660);module.exports=t})();
+ ^---------------^
unable to resolve module "crypto"
| It was not possible to find the requested file.
| Parsed request as written in source code: module "crypto"
| Path where resolving has started: [project]/packages/next/dist/compiled/nanoid/index.cjs
| Type of request: commonjs request
| Import map: No import map entry
|

View file

@ -0,0 +1,13 @@
error - [resolve] [project]/packages/next/dist/compiled/nanoid/index.cjs /packages/next/dist/compiled/nanoid/index.cjs:1:45 Error resolving commonjs request
+ v---------------v
1 + (()=>{var e={113:e=>{"use strict";e.exports=require("crypto")},660:(e,r,t)=>{let l=t(113);let{urlAlphabet:a}=t(591);const n=128;let _,u;let fillPool=e=>{if(!_||...ndefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(660);module.exports=t})();
+ ^---------------^
unable to resolve module "crypto"
| It was not possible to find the requested file.
| Parsed request as written in source code: module "crypto"
| Path where resolving has started: [project]/packages/next/dist/compiled/nanoid/index.cjs
| Type of request: commonjs request
| Import map: No import map entry
|

View file

@ -1,17 +0,0 @@
warning - [parse] [project]/packages/next/dist/server/web/sandbox/context.js /packages/next/dist/server/web/sandbox/context.js:64:56 lint TP1004 fs.readFile(???*0*) is very dynamic
60 | }
61 | async function loadWasm(wasm) {
62 | const modules = {};
63 | await Promise.all(wasm.map(async (binding)=>{
+ v
64 + const module1 = await WebAssembly.compile(await _fs.promises.readFile(binding.filePath));
+ ^
65 | modules[binding.name] = module1;
66 | }));
67 | return modules;
68 | }
- *0* ???*1*["filePath"]
⚠️ unknown object
- *1* binding
⚠️ pattern without value

View file

@ -1,15 +0,0 @@
warning - [parse] [project]/packages/next/dist/server/web/sandbox/context.js /packages/next/dist/server/web/sandbox/context.js:355:28 lint TP1004 fs.readFileSync(???*0*, "utf-8") is very dynamic
351 | }
352 | const moduleContext = lazyModuleContext;
353 | const evaluateInContext = (filepath)=>{
354 | if (!moduleContext.paths.has(filepath)) {
+ v
355 + const content = (0, _fs.readFileSync)(filepath, "utf-8");
+ ^
356 | try {
357 | (0, _vm.runInContext)(content, moduleContext.runtime.context, {
358 | filename: filepath
359 | });
- *0* filepath
⚠️ pattern without value

View file

@ -1,3 +1,3 @@
import getConfig from './dist/shared/lib/runtime-config.shared-runtime'
export * from './dist/shared/lib/runtime-config.shared-runtime'
import getConfig from './dist/shared/lib/runtime-config'
export * from './dist/shared/lib/runtime-config'
export default getConfig

View file

@ -1 +1 @@
module.exports = require('./dist/shared/lib/runtime-config.shared-runtime')
module.exports = require('./dist/shared/lib/runtime-config')

View file

@ -83,7 +83,6 @@
},
"taskr": {
"requires": [
"./taskfile-webpack.js",
"./taskfile-ncc.js",
"./taskfile-swc.js",
"./taskfile-watch.js"
@ -300,7 +299,6 @@
"tar": "6.1.15",
"taskr": "1.1.0",
"terser": "5.14.1",
"terser-webpack-plugin": "5.3.9",
"text-table": "0.2.0",
"timers-browserify": "2.0.12",
"tty-browserify": "0.0.1",

View file

@ -143,13 +143,8 @@ import { createClientRouterFilter } from '../lib/create-client-router-filter'
import { createValidFileMatcher } from '../server/lib/find-page-file'
import { startTypeChecking } from './type-check'
import { generateInterceptionRoutesRewrites } from '../lib/generate-interception-routes-rewrites'
import { buildDataRoute } from '../server/lib/router-utils/build-data-route'
import {
baseOverrides,
defaultOverrides,
experimentalOverrides,
} from '../server/require-hook'
import { baseOverrides, experimentalOverrides } from '../server/require-hook'
import { initialize } from '../server/lib/incremental-cache-server'
import { nodeFs } from '../server/lib/node-fs-methods'
@ -1248,7 +1243,6 @@ export default async function build(
forkOptions: {
env: {
...process.env,
__NEXT_PRIVATE_RENDER_RUNTIME: type,
__NEXT_INCREMENTAL_CACHE_IPC_PORT: ipcPort + '',
__NEXT_INCREMENTAL_CACHE_IPC_KEY: ipcValidationKey,
__NEXT_PRIVATE_PREBUNDLED_REACT:
@ -2090,25 +2084,6 @@ export default async function build(
...Object.values(experimentalOverrides).map((override) =>
require.resolve(override)
),
...(config.experimental.turbotrace
? []
: Object.keys(defaultOverrides).map((value) =>
require.resolve(value, {
paths: [require.resolve('next/dist/server/require-hook')],
})
)),
require.resolve(
'next/dist/compiled/next-server/app-page.runtime.prod'
),
require.resolve(
'next/dist/compiled/next-server/app-route.runtime.prod'
),
require.resolve(
'next/dist/compiled/next-server/pages.runtime.prod'
),
require.resolve(
'next/dist/compiled/next-server/pages-api.runtime.prod'
),
]
// ensure we trace any dependencies needed for custom
@ -2134,7 +2109,10 @@ export default async function build(
const minimalServerEntries = [
...sharedEntriesSet,
require.resolve(
'next/dist/compiled/next-server/server.runtime.prod'
'next/dist/compiled/minimal-next-server/next-server-cached.js'
),
require.resolve(
'next/dist/compiled/minimal-next-server/next-server.js'
),
].filter(Boolean)

View file

@ -1,7 +1,7 @@
import type { LoaderTree } from '../../server/lib/app-dir-module'
// @ts-ignore this need to be imported from next/dist to be external
import * as module from 'next/dist/server/future/route-modules/app-page/module.compiled'
import * as module from 'next/dist/server/future/route-modules/app-page/module'
import { RouteKind } from '../../server/future/route-kind'
const AppPageRouteModule =

View file

@ -1,8 +1,7 @@
import '../../server/node-polyfill-headers'
// @ts-ignore this need to be imported from next/dist to be external
import * as module from 'next/dist/server/future/route-modules/app-route/module.compiled'
import * as module from 'next/dist/server/future/route-modules/app-route/module'
import type { AppRouteRouteModuleOptions } from '../../server/future/route-modules/app-route/module'
import { RouteKind } from '../../server/future/route-kind'

View file

@ -1,6 +1,5 @@
// @ts-ignore this need to be imported from next/dist to be external
import * as module from 'next/dist/server/future/route-modules/pages-api/module.compiled'
import * as module from 'next/dist/server/future/route-modules/pages-api/module'
import { RouteKind } from '../../server/future/route-kind'
import { hoist } from './helpers'

View file

@ -1,5 +1,5 @@
// @ts-ignore this need to be imported from next/dist to be external
import * as module from 'next/dist/server/future/route-modules/pages/module.compiled'
import * as module from 'next/dist/server/future/route-modules/pages/module'
import { RouteKind } from '../../server/future/route-kind'
import { hoist } from './helpers'

View file

@ -14,7 +14,7 @@ import type {
EdgeFunctionDefinition,
MiddlewareManifest,
} from './webpack/plugins/middleware-plugin'
import type { StaticGenerationAsyncStorage } from '../client/components/static-generation-async-storage.external'
import type { StaticGenerationAsyncStorage } from '../client/components/static-generation-async-storage'
import '../server/require-hook'
import '../server/node-polyfill-fetch'
@ -65,9 +65,7 @@ import { nodeFs } from '../server/lib/node-fs-methods'
import * as ciEnvironment from '../telemetry/ci-info'
import { normalizeAppPath } from '../shared/lib/router/utils/app-paths'
import { denormalizeAppPagePath } from '../shared/lib/page-path/denormalize-app-path'
// import { AppRouteRouteModule } from '../server/future/route-modules/app-route/module'
const { AppRouteRouteModule } =
require('../server/future/route-modules/app-route/module.compiled') as typeof import('../server/future/route-modules/app-route/module')
import { AppRouteRouteModule } from '../server/future/route-modules/app-route/module'
export type ROUTER_TYPE = 'pages' | 'app'
@ -1391,9 +1389,7 @@ export async function isPageStatic({
const isPageStaticSpan = trace('is-page-static-utils', parentId)
return isPageStaticSpan
.traceAsyncFn(async () => {
require('../shared/lib/runtime-config.shared-runtime').setConfig(
runtimeEnvConfig
)
require('../shared/lib/runtime-config').setConfig(runtimeEnvConfig)
setHttpClientAndAgentOptions({
httpAgentOptions,
})
@ -1677,9 +1673,7 @@ export async function hasCustomGetInitialProps(
runtimeEnvConfig: any,
checkingApp: boolean
): Promise<boolean> {
require('../shared/lib/runtime-config.shared-runtime').setConfig(
runtimeEnvConfig
)
require('../shared/lib/runtime-config').setConfig(runtimeEnvConfig)
const components = await loadComponents({
distDir,
@ -1702,9 +1696,7 @@ export async function getDefinedNamedExports(
distDir: string,
runtimeEnvConfig: any
): Promise<ReadonlyArray<string>> {
require('../shared/lib/runtime-config.shared-runtime').setConfig(
runtimeEnvConfig
)
require('../shared/lib/runtime-config').setConfig(runtimeEnvConfig)
const components = await loadComponents({
distDir,
pathname: page,

View file

@ -103,19 +103,6 @@ const reactPackagesRegex = /^(react|react-dom|react-server-dom-webpack)($|\/)/
const asyncStoragesRegex =
/next[\\/]dist[\\/](esm[\\/])?client[\\/]components[\\/](static-generation-async-storage|action-async-storage|request-async-storage)/
const pathSeparators = '[/\\\\]'
const optionalEsmPart = `((${pathSeparators}esm)?${pathSeparators})`
const sharedRuntimeFileEnd = '(\\.shared-runtime(\\.js)?)$'
const externalFileEnd = '(\\.external(\\.js)?)$'
const nextDist = `next${pathSeparators}dist`
const sharedRuntimePattern = new RegExp(
`${nextDist}${optionalEsmPart}.*${sharedRuntimeFileEnd}`
)
const externalPattern = new RegExp(
`${nextDist}${optionalEsmPart}.*${externalFileEnd}`
)
// exports.<conditionName>
const edgeConditionNames = [
'edge-light',
@ -1024,7 +1011,7 @@ export default async function getBaseWebpackConfig(
const customRootAliases: { [key: string]: string[] } = {}
if (dev) {
const nextDistPath = 'next/dist/' + (isEdgeServer ? 'esm/' : '')
const nextDist = 'next/dist/' + (isEdgeServer ? 'esm/' : '')
customAppAliases[`${PAGES_DIR_ALIAS}/_app`] = [
...(pagesDir
? pageExtensions.reduce((prev, ext) => {
@ -1032,7 +1019,7 @@ export default async function getBaseWebpackConfig(
return prev
}, [] as string[])
: []),
`${nextDistPath}pages/_app.js`,
`${nextDist}pages/_app.js`,
]
customAppAliases[`${PAGES_DIR_ALIAS}/_error`] = [
...(pagesDir
@ -1041,7 +1028,7 @@ export default async function getBaseWebpackConfig(
return prev
}, [] as string[])
: []),
`${nextDistPath}pages/_error.js`,
`${nextDist}pages/_error.js`,
]
customDocumentAliases[`${PAGES_DIR_ALIAS}/_document`] = [
...(pagesDir
@ -1050,7 +1037,7 @@ export default async function getBaseWebpackConfig(
return prev
}, [] as string[])
: []),
`${nextDistPath}pages/_document.js`,
`${nextDist}pages/_document.js`,
]
}
@ -1324,7 +1311,6 @@ export default async function getBaseWebpackConfig(
WEBPACK_LAYERS.serverSideRendering,
WEBPACK_LAYERS.appPagesBrowser,
WEBPACK_LAYERS.actionBrowser,
WEBPACK_LAYERS.appRouteHandler,
].includes(layer!)
if (
@ -1381,7 +1367,7 @@ export default async function getBaseWebpackConfig(
}
const notExternalModules =
/^(?:private-next-pages\/|next\/(?:dist\/pages\/|(?:app|document|link|image|legacy\/image|constants|dynamic|script|navigation|headers|router)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-action-proxy$)/
/^(?:private-next-pages\/|next\/(?:dist\/pages\/|(?:app|document|link|image|legacy\/image|constants|dynamic|script|navigation|headers)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-action-proxy$)/
if (notExternalModules.test(request)) {
return
}
@ -1404,59 +1390,41 @@ export default async function getBaseWebpackConfig(
// Also disable esm request when appDir is enabled
const isEsmRequested = dependencyType === 'esm'
/**
* @param localRes the full path to the file
* @returns the externalized path
* @description returns an externalized path if the file is a Next.js file and ends with either `.shared-runtime.js` or `.external.js`
* This is used to ensure that files used across the rendering runtime(s) and the user code are one and the same. The logic in this function
* will rewrite the require to the correct bundle location depending on the layer at which the file is being used.
*/
const isLocalCallback = (localRes: string) => {
const isSharedRuntime = sharedRuntimePattern.test(localRes)
const isExternal = externalPattern.test(localRes)
// Makes sure dist/shared and dist/server are not bundled
// we need to process shared `router/router`, `head` and `dynamic`,
// so that the DefinePlugin can inject process.env values.
// if the file ends with .external, we need to make it a commonjs require in all cases
// this is used mainly to share the async local storage across the routing, rendering and user layers.
if (isExternal) {
// it's important we return the path that starts with `next/dist/` here instead of the absolute path
// otherwise NFT will get tripped up
return `commonjs ${localRes.replace(/.*?next[/\\]dist/, 'next/dist')}`
}
// if the file ends with .shared-runtime, we need to make it point to the correct bundle depending on the layer
// this is because each shared-runtime files are unique per bundle, so if you use app-router context in pages,
// it'll be a different instance than the one used in the app-router runtime.
if (isSharedRuntime) {
if (dev) {
return `commonjs ${localRes}`
// Treat next internals as non-external for server layer
if (isWebpackServerLayer(layer)) {
return
}
const name = path.parse(localRes).name.replace('.shared-runtime', '')
const isNextExternal =
/next[/\\]dist[/\\](esm[\\/])?(shared|server)[/\\](?!lib[/\\](router[/\\]router|dynamic|app-dynamic|image-external|lazy-dynamic|head[^-]))/.test(
localRes
) ||
// There's no need to bundle the dev overlay
(process.env.NODE_ENV === 'development' &&
/next[/\\]dist[/\\](esm[/\\])?client[/\\]components[/\\]react-dev-overlay[/\\]/.test(
localRes
))
const camelCaseName = name.replace(/-([a-z])/g, (_, w) =>
w.toUpperCase()
)
// there's no externals for API routes but if need be, they'll need to be added here and have
// their own layer
const runtime =
layer === 'app-route-handler'
? 'app-route'
: isAppLayer
? 'app-page'
: 'pages'
return [
'commonjs ' +
path.posix.join(
if (isNextExternal) {
// Generate Next.js external import
const externalRequest = path.posix.join(
'next',
'dist',
'compiled',
'next-server',
`${runtime}.runtime.${dev ? 'dev' : 'prod'}`
),
'default',
'sharedModules',
camelCaseName,
]
path
.relative(
// Root of Next.js package:
path.join(__dirname, '..'),
localRes
)
// Windows path normalization
.replace(/\\/g, '/')
)
return `commonjs ${externalRequest}`
}
}
@ -1477,10 +1445,6 @@ export default async function getBaseWebpackConfig(
return
}
if (/^next\/dist\/compiled\/next-server/.test(request)) {
return `commonjs ${request}`
}
if (
/^next\/dist\/shared\/(?!lib\/router\/router)/.test(request) ||
/^next\/dist\/compiled\/.*\.c?js$/.test(request)
@ -2067,14 +2031,6 @@ export default async function getBaseWebpackConfig(
},
...(hasAppDir
? [
{
layer: WEBPACK_LAYERS.appRouteHandler,
test: new RegExp(
`private-next-app-dir\\/.*\\/route\\.(${pageExtensions.join(
'|'
)})$`
),
},
{
// Make sure that AsyncLocalStorage module instance is shared between server and client
// layers.
@ -2283,7 +2239,7 @@ export default async function getBaseWebpackConfig(
WEBPACK_LAYERS.appPagesBrowser,
],
},
exclude: [codeCondition.exclude],
exclude: [asyncStoragesRegex, codeCondition.exclude],
use: [
...(dev && isClient
? [

View file

@ -442,7 +442,7 @@ declare module 'next/link' {
declare module 'next/navigation' {
export * from 'next/dist/client/components/navigation.js'
import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'
import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from 'next/dist/shared/lib/app-router-context.js'
interface AppRouterInstance extends OriginalAppRouterInstance {
/**
* Navigate to the provided href.
@ -575,11 +575,8 @@ export class NextTypesPlugin {
}
return
}
if (
mod.layer !== WEBPACK_LAYERS.reactServerComponents &&
mod.layer !== WEBPACK_LAYERS.appRouteHandler
)
return
if (mod.layer !== WEBPACK_LAYERS.reactServerComponents) return
const IS_LAYOUT = /[/\\]layout\.[^./\\]+$/.test(mod.resource)
const IS_PAGE = !IS_LAYOUT && /[/\\]page\.[^.]+$/.test(mod.resource)

View file

@ -7,8 +7,8 @@ import React, { use } from 'react'
// eslint-disable-next-line import/no-extraneous-dependencies
import { createFromReadableStream } from 'react-server-dom-webpack/client'
import { HeadManagerContext } from '../shared/lib/head-manager-context.shared-runtime'
import { GlobalLayoutRouterContext } from '../shared/lib/app-router-context.shared-runtime'
import { HeadManagerContext } from '../shared/lib/head-manager-context'
import { GlobalLayoutRouterContext } from '../shared/lib/app-router-context'
import onRecoverableError from './on-recoverable-error'
import { callServer } from './app-call-server'
import { isNextRouterError } from './components/is-next-router-error'

View file

@ -1,5 +1,5 @@
import { useContext } from 'react'
import { RouterContext } from '../../shared/lib/router-context.shared-runtime'
import { RouterContext } from '../../shared/lib/router-context'
import { NextRouter } from '../router'
/**

View file

@ -14,11 +14,11 @@ import {
LayoutRouterContext,
GlobalLayoutRouterContext,
CacheStates,
} from '../../shared/lib/app-router-context.shared-runtime'
} from '../../shared/lib/app-router-context'
import type {
CacheNode,
AppRouterInstance,
} from '../../shared/lib/app-router-context.shared-runtime'
} from '../../shared/lib/app-router-context'
import type {
FlightRouterState,
FlightData,
@ -44,7 +44,7 @@ import { createHrefFromUrl } from './router-reducer/create-href-from-url'
import {
SearchParamsContext,
PathnameContext,
} from '../../shared/lib/hooks-client-context.shared-runtime'
} from '../../shared/lib/hooks-client-context'
import { useReducerWithReduxDevtools } from './use-reducer-with-devtools'
import { ErrorBoundary } from './error-boundary'
import {

View file

@ -1,5 +1,5 @@
import { suspense } from '../../shared/lib/lazy-dynamic/dynamic-no-ssr'
import { staticGenerationAsyncStorage } from './static-generation-async-storage.external'
import { staticGenerationAsyncStorage } from './static-generation-async-storage'
export function bailoutToClientRendering(): boolean | never {
const staticGenerationStore = staticGenerationAsyncStorage.getStore()

View file

@ -4,8 +4,8 @@ import {
} from '../../server/web/spec-extension/adapters/request-cookies'
import { HeadersAdapter } from '../../server/web/spec-extension/adapters/headers'
import { RequestCookies } from '../../server/web/spec-extension/cookies'
import { requestAsyncStorage } from './request-async-storage.external'
import { actionAsyncStorage } from './action-async-storage.external'
import { requestAsyncStorage } from './request-async-storage'
import { actionAsyncStorage } from './action-async-storage'
import { staticGenerationBailout } from './static-generation-bailout'
import { DraftMode } from './draft-mode'
@ -17,6 +17,7 @@ export function headers() {
) {
return HeadersAdapter.seal(new Headers({}))
}
const requestStore = requestAsyncStorage.getStore()
if (!requestStore) {
throw new Error(

View file

@ -1,6 +1,6 @@
'use client'
import type { ChildSegmentMap } from '../../shared/lib/app-router-context.shared-runtime'
import type { ChildSegmentMap } from '../../shared/lib/app-router-context'
import type {
FlightRouterState,
FlightSegmentPath,
@ -17,7 +17,7 @@ import {
LayoutRouterContext,
GlobalLayoutRouterContext,
TemplateContext,
} from '../../shared/lib/app-router-context.shared-runtime'
} from '../../shared/lib/app-router-context'
import { fetchServerResponse } from './router-reducer/fetch-server-response'
import { createInfinitePromise } from './infinite-promise'
import { ErrorBoundary } from './error-boundary'

View file

@ -4,11 +4,11 @@ import {
AppRouterContext,
GlobalLayoutRouterContext,
LayoutRouterContext,
} from '../../shared/lib/app-router-context.shared-runtime'
} from '../../shared/lib/app-router-context'
import {
SearchParamsContext,
PathnameContext,
} from '../../shared/lib/hooks-client-context.shared-runtime'
} from '../../shared/lib/hooks-client-context'
import { clientHookInServerComponentError } from './client-hook-in-server-component-error'
import { getSegmentValue } from './router-reducer/reducers/get-segment-value'
@ -111,12 +111,12 @@ export function usePathname(): string {
export {
ServerInsertedHTMLContext,
useServerInsertedHTML,
} from '../../shared/lib/server-inserted-html.shared-runtime'
} from '../../shared/lib/server-inserted-html'
/**
* Get the router methods. For example router.push('/dashboard')
*/
export function useRouter(): import('../../shared/lib/app-router-context.shared-runtime').AppRouterInstance {
export function useRouter(): import('../../shared/lib/app-router-context').AppRouterInstance {
clientHookInServerComponentError('useRouter')
const router = useContext(AppRouterContext)
if (router === null) {

View file

@ -1,5 +1,5 @@
import { useCallback, useContext, useEffect, useRef } from 'react'
import { GlobalLayoutRouterContext } from '../../../../../shared/lib/app-router-context.shared-runtime'
import { GlobalLayoutRouterContext } from '../../../../../shared/lib/app-router-context'
import { getSocketUrl } from './get-socket-url'
export function useWebsocket(assetPrefix: string) {

View file

@ -1,6 +1,6 @@
'use client'
import React, { useEffect } from 'react'
import { AppRouterInstance } from '../../shared/lib/app-router-context.shared-runtime'
import { AppRouterInstance } from '../../shared/lib/app-router-context'
import { useRouter } from './navigation'
import {
RedirectType,

View file

@ -1,4 +1,4 @@
import { requestAsyncStorage } from './request-async-storage.external'
import { requestAsyncStorage } from './request-async-storage'
import type { ResponseCookies } from '../../server/web/spec-extension/cookies'
const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT'

View file

@ -1,7 +1,7 @@
'use client'
import React, { useContext } from 'react'
import { TemplateContext } from '../../shared/lib/app-router-context.shared-runtime'
import { TemplateContext } from '../../shared/lib/app-router-context'
export default function RenderFromTemplateContext(): JSX.Element {
const children = useContext(TemplateContext)

View file

@ -1,7 +1,4 @@
import {
CacheNode,
CacheStates,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheNode, CacheStates } from '../../../shared/lib/app-router-context'
import { FlightDataPath } from '../../../server/app-render/types'
import { fillLazyItemsTillLeafWithHead } from './fill-lazy-items-till-leaf-with-head'
import { fillCacheWithNewSubTreeData } from './fill-cache-with-new-subtree-data'

View file

@ -1,9 +1,6 @@
import React from 'react'
import type { FlightRouterState } from '../../../server/app-render/types'
import {
CacheNode,
CacheStates,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheNode, CacheStates } from '../../../shared/lib/app-router-context'
import { createInitialRouterState } from './create-initial-router-state'
const buildId = 'development'

View file

@ -1,8 +1,8 @@
import type { ReactNode } from 'react'
import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime'
import type { CacheNode } from '../../../shared/lib/app-router-context'
import type { FlightRouterState } from '../../../server/app-render/types'
import { CacheStates } from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheStates } from '../../../shared/lib/app-router-context'
import { createHrefFromUrl } from './create-href-from-url'
import { fillLazyItemsTillLeafWithHead } from './fill-lazy-items-till-leaf-with-head'
import { extractPathFromFlightRouterState } from './compute-changed-path'

View file

@ -1,10 +1,7 @@
import React from 'react'
import { fetchServerResponse } from './fetch-server-response'
import { fillCacheWithDataProperty } from './fill-cache-with-data-property'
import {
CacheStates,
CacheNode,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheStates, CacheNode } from '../../../shared/lib/app-router-context'
describe('fillCacheWithDataProperty', () => {
it('should add data property', () => {
const fetchServerResponseMock: jest.Mock<

View file

@ -1,8 +1,5 @@
import { FlightSegmentPath } from '../../../server/app-render/types'
import {
CacheNode,
CacheStates,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheNode, CacheStates } from '../../../shared/lib/app-router-context'
import { createRouterCacheKey } from './create-router-cache-key'
import { fetchServerResponse } from './fetch-server-response'

View file

@ -1,9 +1,6 @@
import React from 'react'
import { fillCacheWithNewSubTreeData } from './fill-cache-with-new-subtree-data'
import {
CacheStates,
CacheNode,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheStates, CacheNode } from '../../../shared/lib/app-router-context'
import type { FlightData } from '../../../server/app-render/types'
const getFlightData = (): FlightData => {

View file

@ -1,7 +1,4 @@
import {
CacheNode,
CacheStates,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheNode, CacheStates } from '../../../shared/lib/app-router-context'
import type { FlightDataPath } from '../../../server/app-render/types'
import { invalidateCacheByRouterState } from './invalidate-cache-by-router-state'
import { fillLazyItemsTillLeafWithHead } from './fill-lazy-items-till-leaf-with-head'

View file

@ -1,9 +1,6 @@
import React from 'react'
import { fillLazyItemsTillLeafWithHead } from './fill-lazy-items-till-leaf-with-head'
import {
CacheStates,
CacheNode,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheStates, CacheNode } from '../../../shared/lib/app-router-context'
import type { FlightData } from '../../../server/app-render/types'
const getFlightData = (): FlightData => {

View file

@ -1,7 +1,4 @@
import {
CacheNode,
CacheStates,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheNode, CacheStates } from '../../../shared/lib/app-router-context'
import type { FlightRouterState } from '../../../server/app-render/types'
import { createRouterCacheKey } from './create-router-cache-key'

View file

@ -1,10 +1,7 @@
import React from 'react'
import type { FlightData } from '../../../server/app-render/types'
import { invalidateCacheBelowFlightSegmentPath } from './invalidate-cache-below-flight-segmentpath'
import {
CacheStates,
CacheNode,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheStates, CacheNode } from '../../../shared/lib/app-router-context'
import { fillCacheWithNewSubTreeData } from './fill-cache-with-new-subtree-data'
const getFlightData = (): FlightData => {

View file

@ -1,4 +1,4 @@
import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime'
import type { CacheNode } from '../../../shared/lib/app-router-context'
import type { FlightSegmentPath } from '../../../server/app-render/types'
import { createRouterCacheKey } from './create-router-cache-key'

View file

@ -1,9 +1,6 @@
import React from 'react'
import { invalidateCacheByRouterState } from './invalidate-cache-by-router-state'
import {
CacheStates,
CacheNode,
} from '../../../shared/lib/app-router-context.shared-runtime'
import { CacheStates, CacheNode } from '../../../shared/lib/app-router-context'
import type { FlightRouterState } from '../../../server/app-render/types'
describe('invalidateCacheByRouterState', () => {

View file

@ -1,4 +1,4 @@
import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime'
import type { CacheNode } from '../../../shared/lib/app-router-context'
import type { FlightRouterState } from '../../../server/app-render/types'
import { createRouterCacheKey } from './create-router-cache-key'

View file

@ -3,7 +3,7 @@ import type { FlightRouterState } from '../../../../server/app-render/types'
import {
CacheNode,
CacheStates,
} from '../../../../shared/lib/app-router-context.shared-runtime'
} from '../../../../shared/lib/app-router-context'
import { findHeadInCache } from './find-head-in-cache'
describe('findHeadInCache', () => {

View file

@ -1,5 +1,5 @@
import type { FlightRouterState } from '../../../../server/app-render/types'
import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime'
import type { CacheNode } from '../../../../shared/lib/app-router-context'
import { createRouterCacheKey } from '../create-router-cache-key'
export function findHeadInCache(

View file

@ -79,7 +79,7 @@ import { FlightRouterState } from '../../../../server/app-render/types'
import {
CacheNode,
CacheStates,
} from '../../../../shared/lib/app-router-context.shared-runtime'
} from '../../../../shared/lib/app-router-context'
import { createInitialRouterState } from '../create-initial-router-state'
import {
NavigateAction,

View file

@ -1,7 +1,7 @@
import {
CacheNode,
CacheStates,
} from '../../../../shared/lib/app-router-context.shared-runtime'
} from '../../../../shared/lib/app-router-context'
import type {
FlightRouterState,
FlightSegmentPath,

View file

@ -36,7 +36,7 @@ import { FlightRouterState } from '../../../../server/app-render/types'
import {
CacheNode,
CacheStates,
} from '../../../../shared/lib/app-router-context.shared-runtime'
} from '../../../../shared/lib/app-router-context'
import { createInitialRouterState } from '../create-initial-router-state'
import {
PrefetchAction,

View file

@ -46,7 +46,7 @@ import { FlightRouterState } from '../../../../server/app-render/types'
import {
CacheNode,
CacheStates,
} from '../../../../shared/lib/app-router-context.shared-runtime'
} from '../../../../shared/lib/app-router-context'
import { createInitialRouterState } from '../create-initial-router-state'
import { RefreshAction, ACTION_REFRESH } from '../router-reducer-types'
import { refreshReducer } from './refresh-reducer'

View file

@ -11,7 +11,7 @@ import {
} from '../router-reducer-types'
import { handleExternalUrl } from './navigate-reducer'
import { handleMutable } from '../handle-mutable'
import { CacheStates } from '../../../../shared/lib/app-router-context.shared-runtime'
import { CacheStates } from '../../../../shared/lib/app-router-context'
import { fillLazyItemsTillLeafWithHead } from '../fill-lazy-items-till-leaf-with-head'
export function refreshReducer(

View file

@ -3,7 +3,7 @@ import type { FlightRouterState } from '../../../../server/app-render/types'
import {
CacheNode,
CacheStates,
} from '../../../../shared/lib/app-router-context.shared-runtime'
} from '../../../../shared/lib/app-router-context'
import { createInitialRouterState } from '../create-initial-router-state'
import { RestoreAction, ACTION_RESTORE } from '../router-reducer-types'
import { restoreReducer } from './restore-reducer'

View file

@ -27,7 +27,7 @@ import { createHrefFromUrl } from '../create-href-from-url'
import { handleExternalUrl } from './navigate-reducer'
import { applyRouterStatePatchToTree } from '../apply-router-state-patch-to-tree'
import { isNavigatingToNewRootLayout } from '../is-navigating-to-new-root-layout'
import { CacheStates } from '../../../../shared/lib/app-router-context.shared-runtime'
import { CacheStates } from '../../../../shared/lib/app-router-context'
import { handleMutable } from '../handle-mutable'
import { fillLazyItemsTillLeafWithHead } from '../fill-lazy-items-till-leaf-with-head'

View file

@ -45,7 +45,7 @@ jest.mock('../fetch-server-response', () => {
import {
CacheNode,
CacheStates,
} from '../../../../shared/lib/app-router-context.shared-runtime'
} from '../../../../shared/lib/app-router-context'
import { createInitialRouterState } from '../create-initial-router-state'
import {
ServerPatchAction,

View file

@ -1,4 +1,4 @@
import type { CacheNode } from '../../../shared/lib/app-router-context.shared-runtime'
import type { CacheNode } from '../../../shared/lib/app-router-context'
import type {
FlightRouterState,
FlightData,

View file

@ -1,5 +1,5 @@
import { DynamicServerError } from './hooks-server-context'
import { staticGenerationAsyncStorage } from './static-generation-async-storage.external'
import { staticGenerationAsyncStorage } from './static-generation-async-storage'
class StaticGenBailoutError extends Error {
code = 'NEXT_STATIC_GEN_BAILOUT'

View file

@ -25,9 +25,9 @@ import type {
ImageLoaderProps,
} from '../shared/lib/image-config'
import { imageConfigDefault } from '../shared/lib/image-config'
import { ImageConfigContext } from '../shared/lib/image-config-context.shared-runtime'
import { ImageConfigContext } from '../shared/lib/image-config-context'
import { warnOnce } from '../shared/lib/utils/warn-once'
import { RouterContext } from '../shared/lib/router-context.shared-runtime'
import { RouterContext } from '../shared/lib/router-context'
// @ts-ignore - This is replaced by webpack alias
import defaultLoader from 'next/dist/shared/lib/image-loader'

View file

@ -10,16 +10,16 @@ import type {
import React from 'react'
import ReactDOM from 'react-dom/client'
import { HeadManagerContext } from '../shared/lib/head-manager-context.shared-runtime'
import { HeadManagerContext } from '../shared/lib/head-manager-context'
import mitt, { MittEmitter } from '../shared/lib/mitt'
import { RouterContext } from '../shared/lib/router-context.shared-runtime'
import { RouterContext } from '../shared/lib/router-context'
import { handleSmoothScroll } from '../shared/lib/router/utils/handle-smooth-scroll'
import { isDynamicRoute } from '../shared/lib/router/utils/is-dynamic'
import {
urlQueryToSearchParams,
assign,
} from '../shared/lib/router/utils/querystring'
import { setConfig } from '../shared/lib/runtime-config.shared-runtime'
import { setConfig } from '../shared/lib/runtime-config'
import {
getURL,
loadGetInitialProps,
@ -34,17 +34,17 @@ import measureWebVitals from './performance-relayer'
import { RouteAnnouncer } from './route-announcer'
import { createRouter, makePublicRouterInstance } from './router'
import { getProperError } from '../lib/is-error'
import { ImageConfigContext } from '../shared/lib/image-config-context.shared-runtime'
import { ImageConfigContext } from '../shared/lib/image-config-context'
import { ImageConfigComplete } from '../shared/lib/image-config'
import { removeBasePath } from './remove-base-path'
import { hasBasePath } from './has-base-path'
import { AppRouterContext } from '../shared/lib/app-router-context.shared-runtime'
import { AppRouterContext } from '../shared/lib/app-router-context'
import {
adaptForAppRouterInstance,
adaptForSearchParams,
PathnameContextProviderAdapter,
} from '../shared/lib/router/adapters.shared-runtime'
import { SearchParamsContext } from '../shared/lib/hooks-client-context.shared-runtime'
} from '../shared/lib/router/adapters'
import { SearchParamsContext } from '../shared/lib/hooks-client-context'
import onRecoverableError from './on-recoverable-error'
import tracer from './tracing/tracer'
import reportToSocket from './tracing/report-to-socket'

View file

@ -16,7 +16,7 @@ import {
VALID_LOADERS,
} from '../../shared/lib/image-config'
import { useIntersection } from '../use-intersection'
import { ImageConfigContext } from '../../shared/lib/image-config-context.shared-runtime'
import { ImageConfigContext } from '../../shared/lib/image-config-context'
import { warnOnce } from '../../shared/lib/utils/warn-once'
import { normalizePathTrailingSlash } from '../normalize-trailing-slash'

View file

@ -12,12 +12,12 @@ import { isLocalURL } from '../shared/lib/router/utils/is-local-url'
import { formatUrl } from '../shared/lib/router/utils/format-url'
import { isAbsoluteUrl } from '../shared/lib/utils'
import { addLocale } from './add-locale'
import { RouterContext } from '../shared/lib/router-context.shared-runtime'
import { RouterContext } from '../shared/lib/router-context'
import {
AppRouterContext,
AppRouterInstance,
PrefetchOptions as AppRouterPrefetchOptions,
} from '../shared/lib/app-router-context.shared-runtime'
} from '../shared/lib/app-router-context'
import { useIntersection } from './use-intersection'
import { getDomainLocale } from './get-domain-locale'
import { addBasePath } from './add-base-path'

View file

@ -2,7 +2,7 @@
import React from 'react'
import Router from '../shared/lib/router/router'
import type { NextRouter } from '../shared/lib/router/router'
import { RouterContext } from '../shared/lib/router-context.shared-runtime'
import { RouterContext } from '../shared/lib/router-context'
import isError from '../lib/is-error'
type SingletonRouterBase = {

View file

@ -3,7 +3,7 @@
import ReactDOM from 'react-dom'
import React, { useEffect, useContext, useRef } from 'react'
import { ScriptHTMLAttributes } from 'react'
import { HeadManagerContext } from '../shared/lib/head-manager-context.shared-runtime'
import { HeadManagerContext } from '../shared/lib/head-manager-context'
import { DOMAttributeNames } from './head-manager'
import { requestIdleCallback } from './request-idle-callback'

View file

@ -59,7 +59,7 @@ import {
RSC,
} from '../client/components/app-router-headers'
const envConfig = require('../shared/lib/runtime-config.shared-runtime')
const envConfig = require('../shared/lib/runtime-config')
;(globalThis as any).__NEXT_DATA__ = {
nextExport: true,
@ -307,10 +307,8 @@ export default async function exportPage({
await promises.mkdir(baseDir, { recursive: true })
let renderResult: RenderResult | undefined
let curRenderOpts: RenderOpts = {}
const renderToHTML =
require('../server/future/route-modules/pages/module.compiled')
.renderToHTML as typeof import('../server/render').renderToHTML
const { renderToHTML } =
require('../server/render') as typeof import('../server/render')
let renderMethod = renderToHTML
let inAmpMode = false,
hybridAmp = false
@ -481,6 +479,7 @@ export default async function exportPage({
const module = await RouteModuleLoader.load<AppRouteRouteModule>(
filename
)
// Call the handler with the request and context from the module.
const response = await module.handle(request, context)
@ -536,9 +535,8 @@ export default async function exportPage({
results.fromBuildExportRevalidate = 0
}
} else {
const renderToHTMLOrFlight =
require('../server/future/route-modules/app-page/module.compiled')
.renderToHTMLOrFlight as typeof import('../server/app-render/app-render').renderToHTMLOrFlight
const { renderToHTMLOrFlight } =
require('../server/app-render/app-render') as typeof import('../server/app-render/app-render')
try {
curRenderOpts.params ||= {}

View file

@ -1,6 +1,6 @@
let chalk: typeof import('next/dist/compiled/chalk')
if (process.env.NEXT_RUNTIME === 'edge' || process.env.NEXT_MINIMAL) {
if (process.env.NEXT_RUNTIME === 'edge') {
chalk = require('./web/chalk').default
} else {
chalk = require('next/dist/compiled/chalk')

View file

@ -132,10 +132,6 @@ const WEBPACK_LAYERS_NAMES = {
* The server bundle layer for metadata routes.
*/
appMetadataRoute: 'app-metadata-route',
/**
* The layer for the server bundle for App Route handlers.
*/
appRouteHandler: 'app-route-handler',
}
export const WEBPACK_LAYERS = {
@ -145,7 +141,6 @@ export const WEBPACK_LAYERS = {
WEBPACK_LAYERS_NAMES.reactServerComponents,
WEBPACK_LAYERS_NAMES.actionBrowser,
WEBPACK_LAYERS_NAMES.appMetadataRoute,
WEBPACK_LAYERS_NAMES.appRouteHandler,
],
},
}

View file

@ -17,11 +17,8 @@ import { BuildManifest, getPageFiles } from '../server/get-page-files'
import { htmlEscapeJsonString } from '../server/htmlescape'
import isError from '../lib/is-error'
import {
HtmlContext,
useHtmlContext,
} from '../shared/lib/html-context.shared-runtime'
import type { HtmlProps } from '../shared/lib/html-context.shared-runtime'
import { HtmlContext, useHtmlContext } from '../shared/lib/html-context'
import type { HtmlProps } from '../shared/lib/html-context'
export { DocumentContext, DocumentInitialProps, DocumentProps }

View file

@ -19,10 +19,10 @@ import {
isRedirectError,
} from '../../client/components/redirect'
import RenderResult from '../render-result'
import { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external'
import { StaticGenerationStore } from '../../client/components/static-generation-async-storage'
import { FlightRenderResult } from './flight-render-result'
import { ActionResult } from './types'
import { ActionAsyncStorage } from '../../client/components/action-async-storage.external'
import { ActionAsyncStorage } from '../../client/components/action-async-storage'
import {
filterReqHeaders,
actionsForbiddenHeaders,
@ -31,8 +31,7 @@ import {
appendMutableCookies,
getModifiedCookieValues,
} from '../web/spec-extension/adapters/request-cookies'
import { RequestStore } from '../../client/components/request-async-storage.external'
import { RequestStore } from '../../client/components/request-async-storage'
import {
NEXT_CACHE_REVALIDATED_TAGS_HEADER,
NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER,

View file

@ -11,9 +11,9 @@ import type {
Segment,
} from './types'
import type { StaticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage.external'
import type { StaticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage'
import type { StaticGenerationBailout } from '../../client/components/static-generation-bailout'
import type { RequestAsyncStorage } from '../../client/components/request-async-storage.external'
import type { RequestAsyncStorage } from '../../client/components/request-async-storage'
import React from 'react'
import { createServerComponentRenderer } from './create-server-components-renderer'
@ -286,13 +286,10 @@ export async function renderToHTMLOrFlight(
* that we need to resolve the final metadata.
*/
let requestId: string
if (process.env.NEXT_RUNTIME === 'edge') {
requestId = crypto.randomUUID()
} else {
requestId = require('next/dist/compiled/nanoid').nanoid()
}
const requestId =
process.env.NEXT_RUNTIME === 'edge'
? crypto.randomUUID()
: require('next/dist/compiled/nanoid').nanoid()
const LayoutRouter =
ComponentMod.LayoutRouter as typeof import('../../client/components/layout-router').default
@ -1395,7 +1392,7 @@ export async function renderToHTMLOrFlight(
)
const { HeadManagerContext } =
require('../../shared/lib/head-manager-context.shared-runtime') as typeof import('../../shared/lib/head-manager-context.shared-runtime')
require('../../shared/lib/head-manager-context') as typeof import('../../shared/lib/head-manager-context')
// On each render, create a new `ServerInsertedHTML` context to capture
// injected nodes from user code (`useServerInsertedHTML`).

View file

@ -1,26 +1,36 @@
const { default: AppRouter } =
require('next/dist/client/components/app-router') as typeof import('../../client/components/app-router')
const { default: LayoutRouter } =
require('next/dist/client/components/layout-router') as typeof import('../../client/components/layout-router')
const { default: RenderFromTemplateContext } =
require('next/dist/client/components/render-from-template-context') as typeof import('../../client/components/render-from-template-context')
const { staticGenerationAsyncStorage } =
require('next/dist/client/components/static-generation-async-storage') as typeof import('../../client/components/static-generation-async-storage')
const { requestAsyncStorage } =
require('next/dist/client/components/request-async-storage') as typeof import('../../client/components/request-async-storage')
const { actionAsyncStorage } =
require('next/dist/client/components/action-async-storage') as typeof import('../../client/components/action-async-storage')
const { staticGenerationBailout } =
require('next/dist/client/components/static-generation-bailout') as typeof import('../../client/components/static-generation-bailout')
const { default: StaticGenerationSearchParamsBailoutProvider } =
require('next/dist/client/components/static-generation-searchparams-bailout-provider') as typeof import('../../client/components/static-generation-searchparams-bailout-provider')
const { createSearchParamsBailoutProxy } =
require('next/dist/client/components/searchparams-bailout-proxy') as typeof import('../../client/components/searchparams-bailout-proxy')
const serverHooks =
require('next/dist/client/components/hooks-server-context') as typeof import('../../client/components/hooks-server-context')
const {
renderToReadableStream,
decodeReply,
decodeAction,
// eslint-disable-next-line import/no-extraneous-dependencies
} = require('react-server-dom-webpack/server.edge')
import AppRouter from '../../client/components/app-router'
import LayoutRouter from '../../client/components/layout-router'
import RenderFromTemplateContext from '../../client/components/render-from-template-context'
import { staticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage.external'
import { requestAsyncStorage } from '../../client/components/request-async-storage.external'
import { actionAsyncStorage } from '../../client/components/action-async-storage.external'
import { staticGenerationBailout } from '../../client/components/static-generation-bailout'
import StaticGenerationSearchParamsBailoutProvider from '../../client/components/static-generation-searchparams-bailout-provider'
import { createSearchParamsBailoutProxy } from '../../client/components/searchparams-bailout-proxy'
import * as serverHooks from '../../client/components/hooks-server-context'
import {
preloadStyle,
preloadFont,
preconnect,
} from '../../server/app-render/rsc/preloads'
const { preloadStyle, preloadFont, preconnect } =
require('next/dist/server/app-render/rsc/preloads') as typeof import('../../server/app-render/rsc/preloads')
const { NotFoundBoundary } =
require('next/dist/client/components/not-found-boundary') as typeof import('../../client/components/not-found-boundary')

View file

@ -2,7 +2,7 @@
// elements into the HTML stream.
import React from 'react'
import { ServerInsertedHTMLContext } from '../../shared/lib/server-inserted-html.shared-runtime'
import { ServerInsertedHTMLContext } from '../../shared/lib/server-inserted-html'
export function createServerInsertedHTML() {
const serverInsertedHTMLCallbacks: (() => React.ReactNode)[] = []

View file

@ -1,7 +1,7 @@
import type { BaseNextRequest, BaseNextResponse } from '../base-http'
import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http'
import type { AsyncLocalStorage } from 'async_hooks'
import type { RequestStore } from '../../client/components/request-async-storage.external'
import type { RequestStore } from '../../client/components/request-async-storage'
import type { RenderOpts } from '../app-render/types'
import type { AsyncStorageWrapper } from './async-storage-wrapper'
import type { NextRequest } from '../web/spec-extension/request'

View file

@ -1,5 +1,5 @@
import type { AsyncStorageWrapper } from './async-storage-wrapper'
import type { StaticGenerationStore } from '../../client/components/static-generation-async-storage.external'
import type { StaticGenerationStore } from '../../client/components/static-generation-async-storage'
import type { AsyncLocalStorage } from 'async_hooks'
import type { IncrementalCache } from '../lib/incremental-cache'

View file

@ -55,7 +55,7 @@ import {
getCookieParser,
checkIsOnDemandRevalidate,
} from './api-utils'
import { setConfig } from '../shared/lib/runtime-config.shared-runtime'
import { setConfig } from '../shared/lib/runtime-config'
import { setRevalidateHeaders } from './send-payload/revalidate-headers'
import { execOnce } from '../shared/lib/utils'
@ -427,11 +427,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
} = this.nextConfig
this.buildId = this.getBuildId()
// this is a hack to avoid Webpack knowing this is equal to this.minimalMode
// because we replace this.minimalMode to true in production bundles.
const minimalModeKey = 'minimalMode'
this[minimalModeKey] =
minimalMode || !!process.env.NEXT_PRIVATE_MINIMAL_MODE
this.minimalMode = minimalMode || !!process.env.NEXT_PRIVATE_MINIMAL_MODE
this.hasAppDir = this.getHasAppDir(dev)
const serverComponents = this.hasAppDir

View file

@ -41,7 +41,7 @@ import {
UnwrapPromise,
withCoalescedInvoke,
} from '../../lib/coalesced-function'
import { loadDefaultErrorComponents } from '../load-default-error-components'
import { loadDefaultErrorComponents } from '../load-components'
import { DecodeError, MiddlewareNotFoundError } from '../../shared/lib/utils'
import * as Log from '../../build/output/log'
import isError, { getProperError } from '../../lib/is-error'

View file

@ -14,10 +14,8 @@ import { loadComponents } from '../load-components'
import { setHttpClientAndAgentOptions } from '../setup-http-agent-env'
import { IncrementalCache } from '../lib/incremental-cache'
import * as serverHooks from '../../client/components/hooks-server-context'
import { staticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage.external'
const { AppRouteRouteModule } =
require('../future/route-modules/app-route/module.compiled') as typeof import('../future/route-modules/app-route/module')
import { staticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage'
import { AppRouteRouteModule } from '../future/route-modules/app-route/module'
type RuntimeConfig = any
@ -58,7 +56,7 @@ export async function loadStaticPaths({
fallback?: boolean | 'blocking'
}> {
// update work memory runtime-config
require('../../shared/lib/runtime-config.shared-runtime').setConfig(config)
require('../../shared/lib/runtime-config').setConfig(config)
setHttpClientAndAgentOptions({
httpAgentOptions,
})

View file

@ -7,10 +7,7 @@ export class NodeModuleLoader implements ModuleLoader {
public async load<M>(id: string): Promise<M> {
if (process.env.NEXT_RUNTIME !== 'edge') {
// Need to `await` to cover the case that route is marked ESM modules by ESM escalation.
return await (process.env.NEXT_MINIMAL
? // @ts-ignore
__non_webpack_require__(id)
: require(id))
return await require(id)
}
throw new Error('NodeModuleLoader is not supported in edge runtime.')

View file

@ -1,11 +0,0 @@
if (process.env.NEXT_RUNTIME === 'edge') {
module.exports = require('next/dist/server/future/route-modules/app-page/module.js')
} else {
if (process.env.NODE_ENV === 'development') {
module.exports = require('next/dist/compiled/next-server/app-page.runtime.dev.js')
} else if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-page-turbo.runtime.prod.js')
} else {
module.exports = require('next/dist/compiled/next-server/app-page.runtime.prod.js')
}
}

View file

@ -11,7 +11,6 @@ import {
type RouteModuleOptions,
type RouteModuleHandleContext,
} from '../route-module'
import * as sharedModules from './shared-modules'
type AppPageUserlandModule = {
/**
@ -35,8 +34,6 @@ export class AppPageRouteModule extends RouteModule<
AppPageRouteDefinition,
AppPageUserlandModule
> {
static readonly sharedModules = sharedModules
public render(
req: IncomingMessage,
res: ServerResponse,
@ -52,6 +49,4 @@ export class AppPageRouteModule extends RouteModule<
}
}
export { renderToHTMLOrFlight }
export default AppPageRouteModule

View file

@ -1,13 +0,0 @@
// the name of the export has to be the camelCase version of the file name (without the extension)
export * as headManagerContext from '../../../../shared/lib/head-manager-context.shared-runtime'
export * as serverInsertedHtml from '../../../../shared/lib/server-inserted-html.shared-runtime'
export * as appRouterContext from '../../../../shared/lib/app-router-context.shared-runtime'
export * as hooksClientContext from '../../../../shared/lib/hooks-client-context.shared-runtime'
export * as routerContext from '../../../../shared/lib/router-context.shared-runtime'
export * as htmlContext from '../../../../shared/lib/html-context.shared-runtime'
export * as ampContext from '../../../../shared/lib/amp-context.shared-runtime'
export * as adapters from '../../../../shared/lib/router/adapters.shared-runtime'
export * as loadableContext from '../../../../shared/lib/loadable-context.shared-runtime'
export * as imageConfigContext from '../../../../shared/lib/image-config-context.shared-runtime'
export * as runtimeConfig from '../../../../shared/lib/runtime-config.shared-runtime'
export * as loadable from '../../../../shared/lib/loadable.shared-runtime'

View file

@ -1,11 +0,0 @@
if (process.env.NEXT_RUNTIME === 'edge') {
module.exports = require('next/dist/server/future/route-modules/app-route/module.js')
} else {
if (process.env.NODE_ENV === 'development') {
module.exports = require('next/dist/compiled/next-server/app-route.runtime.dev.js')
} else if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-route-turbo.runtime.prod.js')
} else {
module.exports = require('next/dist/compiled/next-server/app-route.runtime.prod.js')
}
}

Some files were not shown because too many files have changed in this diff Show more