Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 30 additions & 32 deletions crates/next-api/src/dynamic_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,38 +120,36 @@ pub struct DynamicImportEntries(
pub async fn map_next_dynamic(
graph: ResolvedVc<ModuleGraphLayer>,
) -> Result<Vc<DynamicImportEntries>> {
let actions = graph
.await?
.iter_nodes()
.map(|module| async move {
if module
.ident()
.await?
.layer
.as_ref()
.is_some_and(|layer| layer.name() == "app-client" || layer.name() == "client")
&& let Some(dynamic_entry_module) =
let actions =
graph
.await?
.iter_nodes()
.map(|module| async move {
if let Some(dynamic_entry_module) =
ResolvedVc::try_downcast_type::<NextDynamicEntryModule>(module)
{
return Ok(Some((
module,
DynamicImportEntriesMapType::DynamicEntry(dynamic_entry_module),
)));
}
// TODO add this check once these modules have the correct layer
// if layer.is_some_and(|layer| &**layer == "app-rsc") {
if let Some(client_reference_module) =
ResolvedVc::try_downcast_type::<EcmascriptClientReferenceModule>(module)
{
return Ok(Some((
module,
DynamicImportEntriesMapType::ClientReference(client_reference_module),
)));
}
// }
Ok(None)
})
.try_flat_join()
.await?;
&& module.ident().await?.layer.as_ref().is_some_and(|layer| {
layer.name() == "app-client" || layer.name() == "client"
})
{
return Ok(Some((
module,
DynamicImportEntriesMapType::DynamicEntry(dynamic_entry_module),
)));
}
// TODO add this check once these modules have the correct layer
// if layer.is_some_and(|layer| &**layer == "app-rsc") {
if let Some(client_reference_module) =
ResolvedVc::try_downcast_type::<EcmascriptClientReferenceModule>(module)
{
return Ok(Some((
module,
DynamicImportEntriesMapType::ClientReference(client_reference_module),
)));
}
// }
Ok(None)
})
.try_flat_join()
.await?;
Ok(Vc::cell(actions.into_iter().collect()))
}
2 changes: 1 addition & 1 deletion docs/01-app/02-guides/memory-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Generating source maps consumes extra memory during the build process.

You can disable source map generation by adding `productionBrowserSourceMaps: false` and `experimental.serverSourceMaps: false` to your Next.js configuration.

When using the `cacheComponents` feature, Next.js will use source maps by default during the prerender phase of `next build`.
Next.js will use source maps by default during the prerender phase of `next build`.
If you consistently encounter memory issues during that phase (after "Generating static pages"),
you can try disabling source maps in that phase by adding `enablePrerenderSourceMaps: false` to your Next.js configuration.

Expand Down
2 changes: 0 additions & 2 deletions docs/01-app/03-api-reference/06-cli/next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,6 @@ This enables several experimental options to make debugging easier:
- `experimental.turbopackMinify = false`
- Generates source maps for server bundles:
- `experimental.serverSourceMaps = true`
- Enables source map consumption in child processes used for prerendering:
- `enablePrerenderSourceMaps = true`
- Continues building even after the first prerender error, so you can see all issues at once:
- `experimental.prerenderEarlyExit = false`

Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,7 @@ export interface NextConfig {
/**
* Enables source maps while generating static pages.
* Helps with errors during the prerender phase in `next build`.
* Defaults to `true`. Set to `false` to disable.
*/
enablePrerenderSourceMaps?: boolean

Expand Down Expand Up @@ -1799,8 +1800,7 @@ export const defaultConfig = Object.freeze({
modularizeImports: undefined,
outputFileTracingRoot: process.env.NEXT_PRIVATE_OUTPUT_TRACE_ROOT || '',
allowedDevOrigins: undefined,
// Will default to cacheComponents value.
enablePrerenderSourceMaps: undefined,
enablePrerenderSourceMaps: true,
cacheComponents: false,
cacheLife: {
default: {
Expand Down
8 changes: 0 additions & 8 deletions packages/next/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1459,11 +1459,6 @@ function assignDefaultsAndValidate(
if (result.cacheComponents) {
// TODO: remove once we've finished migrating internally to cacheComponents.
result.experimental.ppr = true

// Prerender sourcemaps are enabled by default when using cacheComponents, unless explicitly disabled.
if (result.enablePrerenderSourceMaps === undefined) {
result.enablePrerenderSourceMaps = true
}
}

// "use cache" was originally implicitly enabled with the cacheComponents flag, so
Expand Down Expand Up @@ -2025,9 +2020,6 @@ function enforceExperimentalFeatures(
debugPrerender &&
(phase === PHASE_PRODUCTION_BUILD || phase === PHASE_EXPORT)
) {
// TODO: This is not an experimental feature, but should be enabled alongside other prerender debugging features.
config.enablePrerenderSourceMaps = true

setExperimentalFeatureForDebugPrerender(
config.experimental,
'serverSourceMaps',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* @type {import('next').NextConfig}
*/
const nextConfig = {
enablePrerenderSourceMaps: false,

cacheComponents: true,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* @type {import('next').NextConfig}
*/
const nextConfig = {
enablePrerenderSourceMaps: true,
experimental: {
cpus: 1,
serverSourceMaps: true,
Expand Down
5 changes: 3 additions & 2 deletions turbopack/crates/turbopack-ecmascript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ use crate::{
analyze_ecmascript_module,
async_module::OptionAsyncModule,
esm::{UrlRewriteBehavior, base::EsmAssetReferences, export},
exports::compute_ecmascript_module_exports,
},
side_effect_optimization::reference::EcmascriptModulePartReference,
swc_comments::{CowComments, ImmutableComments},
Expand Down Expand Up @@ -676,7 +677,7 @@ impl EcmascriptAnalyzable for EcmascriptModuleAsset {
async_module: analyze_ref.async_module,
generate_source_map,
original_source_map: analyze_ref.source_map,
exports: analyze_ref.exports,
exports: self.get_exports().to_resolved().await?,
async_module_info,
}
.cell())
Expand Down Expand Up @@ -896,7 +897,7 @@ impl ChunkableModule for EcmascriptModuleAsset {
impl EcmascriptChunkPlaceable for EcmascriptModuleAsset {
#[turbo_tasks::function]
async fn get_exports(self: Vc<Self>) -> Result<Vc<EcmascriptExports>> {
Ok(*self.analyze().await?.exports)
Ok(*compute_ecmascript_module_exports(self, None).await?.exports)
}

#[turbo_tasks::function]
Expand Down
Loading
Loading