Skip to content

Commit 57a7fa7

Browse files
committed
add to turbopack-cli
1 parent f38edc7 commit 57a7fa7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

turbopack/crates/turbopack-cli/src/contexts.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ use turbo_tasks::{ResolvedVc, Vc};
66
use turbo_tasks_fs::{FileSystem, FileSystemPath};
77
use turbopack::{
88
ModuleAssetContext,
9+
collect_module::CollectModuleType,
910
module_options::{
10-
EcmascriptOptionsContext, JsxTransformOptions, ModuleOptionsContext,
11-
TypescriptTransformOptions,
11+
EcmascriptOptionsContext, JsxTransformOptions, ModuleOptionsContext, ModuleRule,
12+
ModuleRuleEffect, ModuleType, RuleCondition, TypescriptTransformOptions,
1213
},
1314
};
1415
use turbopack_browser::react_refresh::assert_can_resolve_react_refresh;
@@ -21,6 +22,7 @@ use turbopack_core::{
2122
environment::{BrowserEnvironment, Environment, ExecutionEnvironment},
2223
free_var_references,
2324
ident::Layer,
25+
reference_type::ReferenceTypeCondition,
2426
resolve::options::{ImportMap, ImportMapping},
2527
};
2628
use turbopack_ecmascript::TreeShakingMode;
@@ -116,6 +118,12 @@ async fn get_client_module_options_context(
116118
execution_context: Some(execution_context),
117119
tree_shaking_mode: Some(TreeShakingMode::ReexportsOnly),
118120
keep_last_successful_parse: is_dev,
121+
module_rules: vec![ModuleRule::new(
122+
RuleCondition::ReferenceType(ReferenceTypeCondition::Collect),
123+
vec![ModuleRuleEffect::ModuleType(ModuleType::Custom(
124+
ResolvedVc::upcast(CollectModuleType::new().to_resolved().await?),
125+
))],
126+
)],
119127
..Default::default()
120128
};
121129

0 commit comments

Comments
 (0)