Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(next-core): mark turbopack embed fs to be internals #65420

Merged
merged 1 commit into from
May 6, 2024
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
14 changes: 11 additions & 3 deletions packages/next-swc/crates/next-core/src/next_client/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ pub async fn get_client_resolve_options_context(
.cell())
}

fn internal_assets_conditions() -> ContextCondition {
ContextCondition::any(vec![
ContextCondition::InPath(next_js_fs().root()),
ContextCondition::InPath(
turbopack_binding::turbopack::ecmascript_runtime::embed_fs().root(),
),
ContextCondition::InPath(turbopack_binding::turbopack::node::embed_js::embed_fs().root()),
])
}

#[turbo_tasks::function]
pub async fn get_client_module_options_context(
project_path: Vc<FileSystemPath>,
Expand Down Expand Up @@ -288,10 +298,8 @@ pub async fn get_client_module_options_context(
foreign_code_context_condition(next_config, project_path).await?,
foreign_codes_options_context.cell(),
),
// If the module is an internal asset (i.e overlay, fallback) coming from the embedded
// FS, don't apply user defined transforms.
(
ContextCondition::InPath(next_js_fs().root()),
internal_assets_conditions(),
ModuleOptionsContext {
enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()),
enable_jsx: Some(JsxTransformOptions::default().cell()),
Expand Down
27 changes: 22 additions & 5 deletions packages/next-swc/crates/next-core/src/next_server/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,23 @@ pub async fn get_server_compile_time_info(
.cell()
}

/// Determins if the module is an internal asset (i.e overlay, fallback) coming
/// from the embedded FS, don't apply user defined transforms.
///
/// [TODO] turbopack specific embed fs should be handled by internals of
/// turbopack itself and user config should not try to leak this. However,
/// currently we apply few transform options subject to next.js's configuration
/// even if it's embedded assets.
fn internal_assets_conditions() -> ContextCondition {
ContextCondition::any(vec![
ContextCondition::InPath(next_js_fs().root()),
ContextCondition::InPath(
turbopack_binding::turbopack::ecmascript_runtime::embed_fs().root(),
),
ContextCondition::InPath(turbopack_binding::turbopack::node::embed_js::embed_fs().root()),
])
}

#[turbo_tasks::function]
pub async fn get_server_module_options_context(
project_path: Vc<FileSystemPath>,
Expand Down Expand Up @@ -485,7 +502,7 @@ pub async fn get_server_module_options_context(
foreign_code_module_options_context.cell(),
),
(
ContextCondition::InPath(next_js_fs().root()),
internal_assets_conditions(),
internal_module_options_context.cell(),
),
],
Expand Down Expand Up @@ -537,7 +554,7 @@ pub async fn get_server_module_options_context(
foreign_code_module_options_context.cell(),
),
(
ContextCondition::InPath(next_js_fs().root()),
internal_assets_conditions(),
internal_module_options_context.cell(),
),
],
Expand Down Expand Up @@ -604,7 +621,7 @@ pub async fn get_server_module_options_context(
foreign_code_module_options_context.cell(),
),
(
ContextCondition::InPath(next_js_fs().root()),
internal_assets_conditions(),
internal_module_options_context.cell(),
),
],
Expand Down Expand Up @@ -667,7 +684,7 @@ pub async fn get_server_module_options_context(
foreign_code_module_options_context.cell(),
),
(
ContextCondition::InPath(next_js_fs().root()),
internal_assets_conditions(),
internal_module_options_context.cell(),
),
],
Expand Down Expand Up @@ -714,7 +731,7 @@ pub async fn get_server_module_options_context(
foreign_code_module_options_context.cell(),
),
(
ContextCondition::InPath(next_js_fs().root()),
internal_assets_conditions(),
internal_module_options_context.cell(),
),
],
Expand Down
Loading