Skip to content

Commit 47f8e55

Browse files
committed
less config inlining
1 parent 4488399 commit 47f8e55

File tree

7 files changed

+7
-45
lines changed

7 files changed

+7
-45
lines changed

crates/next-api/src/pages.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,6 @@ impl PageEndpoint {
897897
this.original_name.clone(),
898898
*this.pages_structure,
899899
runtime,
900-
this.pages_project.project().next_config(),
901900
)
902901
.await?;
903902

@@ -918,7 +917,6 @@ impl PageEndpoint {
918917
this.original_name.clone(),
919918
*this.pages_structure,
920919
runtime,
921-
this.pages_project.project().next_config(),
922920
)
923921
.await?;
924922
InternalSsrChunkModule {

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_pages/page_entry.rs

Lines changed: 0 additions & 9 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;
@@ -169,7 +167,6 @@ pub async fn create_page_ssr_entry_module(
169167
definition_pathname.clone(),
170168
reference_type,
171169
pages_structure,
172-
next_config,
173170
source_query.clone(),
174171
);
175172
} else {
@@ -213,7 +210,6 @@ async fn wrap_edge_page(
213210
pathname: RcStr,
214211
reference_type: ReferenceType,
215212
pages_structure: Vc<PagesStructure>,
216-
next_config: Vc<NextConfig>,
217213
source_query: RcStr,
218214
) -> Result<Vc<Box<dyn Module>>> {
219215
const INNER: &str = "INNER_PAGE_ENTRY";
@@ -223,8 +219,6 @@ async fn wrap_edge_page(
223219
const INNER_ERROR: &str = "INNER_ERROR";
224220
const INNER_ERROR_500: &str = "INNER_500";
225221

226-
let next_config_val = &*next_config.await?;
227-
228222
let source = load_next_js_template(
229223
"edge-ssr.js",
230224
project_root.clone(),
@@ -236,9 +230,6 @@ async fn wrap_edge_page(
236230
("VAR_MODULE_GLOBAL_ERROR", INNER_ERROR),
237231
],
238232
&[
239-
// TODO do we really need to pass the entire next config here?
240-
// This is bad for invalidation as any config change will invalidate this
241-
("nextConfig", &*serde_json::to_string(next_config_val)?),
242233
(
243234
"pageRouteModuleOptions",
244235
&serde_json::to_string(&get_route_module_options(page.clone(), pathname.clone()))?,

packages/next/src/build/entries.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,6 @@ export function getEdgeServerEntry(opts: {
682682
dev: opts.isDev,
683683
isServerComponent: opts.isServerComponent,
684684
page: opts.page,
685-
stringifiedConfig: Buffer.from(JSON.stringify(opts.config)).toString(
686-
'base64'
687-
),
688685
pagesType: opts.pagesType,
689686
appDirLoader: Buffer.from(opts.appDirLoader || '').toString('base64'),
690687
sriEnabled: !opts.isDev && !!opts.config.experimental.sri?.algorithm,

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 { NextConfigComplete } 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: NextConfigComplete
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 { NextConfigComplete } 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: NextConfigComplete
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,
@@ -107,6 +101,7 @@ async function requestHandler(
107101
query,
108102
params,
109103
buildId,
104+
nextConfig,
110105
isNextDataRequest,
111106
buildManifest,
112107
prerenderManifest,

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export type EdgeSSRLoaderQuery = {
1919
dev: boolean
2020
isServerComponent: boolean
2121
page: string
22-
stringifiedConfig: string
2322
appDirLoader?: string
2423
pagesType: PAGE_TYPES
2524
sriEnabled: boolean
@@ -73,7 +72,6 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
7372
absolute500Path,
7473
absoluteErrorPath,
7574
isServerComponent,
76-
stringifiedConfig: stringifiedConfigBase64,
7775
appDirLoader: appDirLoaderBase64,
7876
pagesType,
7977
cacheHandler,
@@ -94,10 +92,6 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
9492
Buffer.from(middlewareConfigBase64, 'base64').toString()
9593
)
9694

97-
const stringifiedConfig = Buffer.from(
98-
stringifiedConfigBase64 || '',
99-
'base64'
100-
).toString()
10195
const appDirLoader = Buffer.from(
10296
appDirLoaderBase64 || '',
10397
'base64'
@@ -160,9 +154,7 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
160154
VAR_USERLAND: pageModPath,
161155
VAR_PAGE: page,
162156
},
163-
{
164-
nextConfig: stringifiedConfig,
165-
},
157+
{},
166158
{
167159
incrementalCacheHandler: cacheHandler ?? null,
168160
}
@@ -178,7 +170,6 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
178170
VAR_MODULE_GLOBAL_ERROR: errorPath,
179171
},
180172
{
181-
nextConfig: stringifiedConfig,
182173
pageRouteModuleOptions: JSON.stringify(getRouteModuleOptions(page)),
183174
errorRouteModuleOptions: JSON.stringify(
184175
getRouteModuleOptions('/_error')

0 commit comments

Comments
 (0)