Skip to content

Commit 3418748

Browse files
committed
less config inlining
1 parent 766f29d commit 3418748

File tree

13 files changed

+46
-74
lines changed

13 files changed

+46
-74
lines changed

crates/next-api/src/pages.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,6 @@ impl PageEndpoint {
904904
this.original_name.clone(),
905905
*this.pages_structure,
906906
runtime,
907-
this.pages_project.project().next_config(),
908907
)
909908
.await?;
910909

crates/next-core/src/next_app/app_page_entry.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ pub async fn get_app_page_entry(
122122
project_root.clone(),
123123
rsc_entry,
124124
page,
125-
next_config,
126125
);
127126
};
128127

@@ -141,21 +140,14 @@ async fn wrap_edge_page(
141140
project_root: FileSystemPath,
142141
entry: ResolvedVc<Box<dyn Module>>,
143142
page: AppPage,
144-
next_config: Vc<NextConfig>,
145143
) -> Result<Vc<Box<dyn Module>>> {
146144
const INNER: &str = "INNER_PAGE_ENTRY";
147145

148-
let next_config_val = &*next_config.await?;
149-
150146
let source = load_next_js_template(
151147
"edge-ssr-app.js",
152148
project_root.clone(),
153149
[("VAR_USERLAND", INNER), ("VAR_PAGE", &page.to_string())],
154-
[
155-
// TODO do we really need to pass the entire next config here?
156-
// This is bad for invalidation as any config change will invalidate this
157-
("nextConfig", &*serde_json::to_string(next_config_val)?),
158-
],
150+
[],
159151
[("incrementalCacheHandler", None)],
160152
)
161153
.await?;

crates/next-core/src/next_app/app_route_entry.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ pub async fn get_app_route_entry(
113113
project_root,
114114
rsc_entry,
115115
page,
116-
next_config,
117116
);
118117
}
119118

@@ -132,17 +131,14 @@ async fn wrap_edge_route(
132131
project_root: FileSystemPath,
133132
entry: ResolvedVc<Box<dyn Module>>,
134133
page: AppPage,
135-
next_config: Vc<NextConfig>,
136134
) -> Result<Vc<Box<dyn Module>>> {
137135
let inner = rcstr!("INNER_ROUTE_ENTRY");
138136

139-
let next_config = &*next_config.await?;
140-
141137
let source = load_next_js_template(
142138
"edge-app-route.js",
143139
project_root.clone(),
144140
[("VAR_USERLAND", &*inner), ("VAR_PAGE", &page.to_string())],
145-
[("nextConfig", &*serde_json::to_string(next_config)?)],
141+
[],
146142
[],
147143
)
148144
.await?;

crates/next-core/src/next_pages/page_entry.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use turbopack_core::{
1616
};
1717

1818
use crate::{
19-
next_config::NextConfig,
2019
next_edge::entry::wrap_edge_entry,
2120
pages_structure::{PagesStructure, PagesStructureItem},
2221
util::{NextRuntime, file_content_rope, load_next_js_template, pages_function_name},
@@ -39,7 +38,6 @@ pub async fn create_page_ssr_entry_module(
3938
next_original_name: RcStr,
4039
pages_structure: Vc<PagesStructure>,
4140
runtime: NextRuntime,
42-
next_config: Vc<NextConfig>,
4341
) -> Result<Vc<PageSsrEntryModule>> {
4442
let definition_page = next_original_name;
4543
let definition_pathname = pathname;
@@ -99,11 +97,7 @@ pub async fn create_page_ssr_entry_module(
9997
let pages_structure_ref = pages_structure.await?;
10098

10199
let (injections, imports) = if is_page && runtime == NextRuntime::Edge {
102-
let next_config_val = &*next_config.await?;
103100
let injections = vec![
104-
// TODO do we really need to pass the entire next config here?
105-
// This is bad for invalidation as any config change will invalidate this
106-
("nextConfig", serde_json::to_string(next_config_val)?),
107101
(
108102
"pageRouteModuleOptions",
109103
serde_json::to_string(&get_route_module_options(

packages/next/errors.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,5 +965,6 @@
965965
"964": "An unexpected error occurred while starting to capture immediates",
966966
"965": "Expected setImmediate to reject invalid arguments",
967967
"966": "Expected process.nextTick to reject invalid arguments",
968-
"967": "The key \"%s\" under \"env\" in %sconfig is not allowed. https://nextjs.org/docs/messages/env-key-not-allowed"
968+
"967": "The key \"%s\" under \"env\" in %sconfig is not allowed. https://nextjs.org/docs/messages/env-key-not-allowed",
969+
"968": "Invariant: getNextConfigEdge most only be called in edge runtime"
969970
}

packages/next/src/build/entries.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,6 @@ export function getEdgeServerEntry(opts: {
621621
absolutePagePath: opts.absolutePagePath,
622622
page: opts.page,
623623
appDirLoader: Buffer.from(opts.appDirLoader || '').toString('base64'),
624-
nextConfig: Buffer.from(JSON.stringify(opts.config)).toString('base64'),
625624
preferredRegion: opts.preferredRegion,
626625
middlewareConfig: Buffer.from(
627626
JSON.stringify(opts.middlewareConfig || {})
@@ -682,9 +681,6 @@ export function getEdgeServerEntry(opts: {
682681
dev: opts.isDev,
683682
isServerComponent: opts.isServerComponent,
684683
page: opts.page,
685-
stringifiedConfig: Buffer.from(JSON.stringify(opts.config)).toString(
686-
'base64'
687-
),
688684
pagesType: opts.pagesType,
689685
appDirLoader: Buffer.from(opts.appDirLoader || '').toString('base64'),
690686
sriEnabled: !opts.isDev && !!opts.config.experimental.sri?.algorithm,

packages/next/src/build/templates/edge-app-route.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { setManifestsSingleton } from '../../server/app-render/manifests-singleton'
2-
import type { NextConfigRuntime } from '../../server/config-shared'
32
import type { EdgeHandler } from '../../server/web/adapter'
43
import { EdgeRouteModuleWrapper } from '../../server/web/edge-route-module-wrapper'
54

65
// Import the userland code.
76
import * as module from 'VAR_USERLAND'
87

98
// injected by the loader afterwards.
10-
declare const nextConfig: NextConfigRuntime
11-
// INJECT:nextConfig
129

1310
const maybeJSONParse = (str?: string) => (str ? JSON.parse(str) : undefined)
1411

@@ -26,7 +23,6 @@ if (rscManifest && rscServerManifest) {
2623
export const ComponentMod = module
2724

2825
const handler: EdgeHandler = EdgeRouteModuleWrapper.wrap(module.routeModule, {
29-
nextConfig,
3026
page: 'VAR_PAGE',
3127
})
3228
export default handler

packages/next/src/build/templates/edge-ssr-app.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { IncrementalCache } from '../../server/lib/incremental-cache'
88

99
import * as pageMod from 'VAR_USERLAND'
1010

11-
import type { NextConfigRuntime } from '../../server/config-shared'
1211
import { setManifestsSingleton } from '../../server/app-render/manifests-singleton'
1312
import { initializeCacheHandlers } from '../../server/use-cache/handlers'
1413
import { BaseServerSpan } from '../../server/lib/trace/constants'
@@ -29,9 +28,7 @@ import { checkIsOnDemandRevalidate } from '../../server/api-utils'
2928
import { CloseController } from '../../server/web/web-on-close'
3029

3130
declare const incrementalCacheHandler: any
32-
declare const nextConfig: NextConfigRuntime
3331
// OPTIONAL_IMPORT:incrementalCacheHandler
34-
// INJECT:nextConfig
3532

3633
const maybeJSONParse = (str?: string) => (str ? JSON.parse(str) : undefined)
3734

@@ -74,6 +71,7 @@ async function requestHandler(
7471
query,
7572
params,
7673
buildId,
74+
nextConfig,
7775
buildManifest,
7876
prerenderManifest,
7977
reactLoadableManifest,

packages/next/src/build/templates/edge-ssr.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import RouteModule, {
2222
} from '../../server/route-modules/pages/module'
2323
import { WebNextRequest, WebNextResponse } from '../../server/base-http/web'
2424

25-
import type { NextConfigRuntime } from '../../server/config-shared'
2625
import type { NextFetchEvent } from '../../server/web/spec-extension/fetch-event'
2726
import type RenderResult from '../../server/render-result'
2827
import type { RenderResultMetadata } from '../../server/render-result'
@@ -31,17 +30,12 @@ import { BaseServerSpan } from '../../server/lib/trace/constants'
3130
import { HTML_CONTENT_TYPE_HEADER } from '../../lib/constants'
3231

3332
// injected by the loader afterwards.
34-
declare const nextConfig: NextConfigRuntime
3533
declare const pageRouteModuleOptions: any
3634
declare const errorRouteModuleOptions: any
3735
declare const user500RouteModuleOptions: any
38-
// INJECT:nextConfig
39-
// INJECT:pageRouteModuleOptions
40-
// INJECT:errorRouteModuleOptions
41-
// INJECT:user500RouteModuleOptions
42-
43-
// expose this for the route-module
44-
;(globalThis as any).nextConfig = nextConfig
36+
// INJECT:pageRouteModuleOptions
37+
// INJECT:errorRouteModuleOptions
38+
// INJECT:user500RouteModuleOptions
4539

4640
const pageMod = {
4741
...userlandPage,
@@ -113,6 +107,7 @@ async function requestHandler(
113107
query,
114108
params,
115109
buildId,
110+
nextConfig,
116111
isNextDataRequest,
117112
buildManifest,
118113
prerenderManifest,

packages/next/src/build/webpack/loaders/next-edge-app-route-loader/index.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export type EdgeAppRouteLoaderQuery = {
1111
page: string
1212
appDirLoader: string
1313
preferredRegion: string | string[] | undefined
14-
nextConfig: string
1514
middlewareConfig: string
1615
cacheHandlers: string
1716
}
@@ -24,7 +23,6 @@ const EdgeAppRouteLoader: webpack.LoaderDefinitionFunction<EdgeAppRouteLoaderQue
2423
preferredRegion,
2524
appDirLoader: appDirLoaderBase64 = '',
2625
middlewareConfig: middlewareConfigBase64 = '',
27-
nextConfig: nextConfigBase64,
2826
cacheHandlers: cacheHandlersStringified,
2927
} = this.getOptions()
3028

@@ -64,20 +62,13 @@ const EdgeAppRouteLoader: webpack.LoaderDefinitionFunction<EdgeAppRouteLoaderQue
6462
stringifiedPagePath.length - 1
6563
)}?${WEBPACK_RESOURCE_QUERIES.edgeSSREntry}`
6664

67-
const stringifiedConfig = Buffer.from(
68-
nextConfigBase64 || '',
69-
'base64'
70-
).toString()
71-
7265
return await loadEntrypoint(
7366
'edge-app-route',
7467
{
7568
VAR_USERLAND: modulePath,
7669
VAR_PAGE: page,
7770
},
78-
{
79-
nextConfig: stringifiedConfig,
80-
}
71+
{}
8172
)
8273
}
8374

0 commit comments

Comments
 (0)