Skip to content

Commit b0a2a2f

Browse files
committed
less config inlining
1 parent 7ebca20 commit b0a2a2f

File tree

13 files changed

+47
-78
lines changed

13 files changed

+47
-78
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_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 & 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/errors.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,5 +964,7 @@
964964
"963": "Fast setImmediate is not available in the edge runtime.",
965965
"964": "An unexpected error occurred while starting to capture immediates",
966966
"965": "Expected setImmediate to reject invalid arguments",
967-
"966": "Expected process.nextTick to reject invalid arguments"
967+
"966": "Expected process.nextTick to reject invalid arguments",
968+
"967": "Invariant: relativeProjectDir cannot be an empty string",
969+
"968": "Invariant: getNextConfigEdge most only be called in edge runtime"
968970
}

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 { NextConfigComplete } 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: NextConfigComplete
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 { 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-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)