Unverified Commit c00f7325 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: sync NFT context configs (#82781)

Keep Turbopack's NFT resolve options in sync with the NFT unit tests so that we are actually asserting the production behvior.
parent 0fdaf937
...@@ -670,12 +670,13 @@ async fn externals_tracing_module_context( ...@@ -670,12 +670,13 @@ async fn externals_tracing_module_context(
compile_time_info: Vc<CompileTimeInfo>, compile_time_info: Vc<CompileTimeInfo>,
) -> Result<Vc<ModuleAssetContext>> { ) -> Result<Vc<ModuleAssetContext>> {
let resolve_options = ResolveOptionsContext { let resolve_options = ResolveOptionsContext {
enable_node_native_modules: true,
emulate_environment: Some(compile_time_info.await?.environment), emulate_environment: Some(compile_time_info.await?.environment),
loose_errors: true, loose_errors: true,
custom_conditions: match ty { custom_conditions: match ty {
ExternalType::CommonJs => vec![rcstr!("require")], ExternalType::CommonJs => vec![rcstr!("require"), rcstr!("node")],
ExternalType::EcmaScriptModule => vec![rcstr!("import")], ExternalType::EcmaScriptModule => vec![rcstr!("import"), rcstr!("node")],
ExternalType::Url | ExternalType::Global | ExternalType::Script => vec![], ExternalType::Url | ExternalType::Global | ExternalType::Script => vec![rcstr!("node")],
}, },
..Default::default() ..Default::default()
}; };
...@@ -688,11 +689,14 @@ async fn externals_tracing_module_context( ...@@ -688,11 +689,14 @@ async fn externals_tracing_module_context(
// are actually representative of what Turbopack does. // are actually representative of what Turbopack does.
ModuleOptionsContext { ModuleOptionsContext {
ecmascript: EcmascriptOptionsContext { ecmascript: EcmascriptOptionsContext {
// enable_types should not be enabled here. It gets set automatically when a TS file
// is encountered.
source_maps: SourceMapsType::None, source_maps: SourceMapsType::None,
..Default::default() ..Default::default()
}, },
css: CssOptionsContext { css: CssOptionsContext {
source_maps: SourceMapsType::None, source_maps: SourceMapsType::None,
enable_raw_css: true,
..Default::default() ..Default::default()
}, },
// Environment is not passed in order to avoid downleveling JS / CSS for // Environment is not passed in order to avoid downleveling JS / CSS for
......
...@@ -338,9 +338,10 @@ async fn node_file_trace_operation( ...@@ -338,9 +338,10 @@ async fn node_file_trace_operation(
)); ));
let module_asset_context = ModuleAssetContext::new( let module_asset_context = ModuleAssetContext::new(
Default::default(), Default::default(),
// TODO It's easy to make a mistake here as this should match the config in the // TODO These test cases should move into the `node-file-trace` crate and use the same
// binary. TODO These test cases should move into the // config.
// `node-file-trace` crate and use the same config. // It's easy to make a mistake here as this should match the config in the binary from
// turbopack/crates/turbopack/src/lib.rs
CompileTimeInfo::new(environment), CompileTimeInfo::new(environment),
ModuleOptionsContext { ModuleOptionsContext {
ecmascript: EcmascriptOptionsContext { ecmascript: EcmascriptOptionsContext {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment