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

allow to create stress test for client components #4581

Merged
merged 2 commits into from
Apr 14, 2023
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
5 changes: 5 additions & 0 deletions crates/turbopack-create-test-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ struct Args {
/// How to communicate changes to the consumer (none | hook | component)
#[clap(long, default_value = "none")]
effect_mode: EffectMode,

/// Make leaf modules client components for app dir
#[clap(long, default_value_t = false)]
leaf_client_components: bool,
}

fn main() -> Result<()> {
Expand All @@ -53,6 +57,7 @@ fn main() -> Result<()> {
None
},
effect_mode: args.effect_mode,
leaf_client_components: args.leaf_client_components,
}
.build()?
.path()
Expand Down
9 changes: 9 additions & 0 deletions crates/turbopack-create-test-app/src/test_app_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub struct TestAppBuilder {
pub flatness: usize,
pub package_json: Option<PackageJsonConfig>,
pub effect_mode: EffectMode,
pub leaf_client_components: bool,
}

impl Default for TestAppBuilder {
Expand All @@ -88,6 +89,7 @@ impl Default for TestAppBuilder {
flatness: 5,
package_json: Some(Default::default()),
effect_mode: EffectMode::Hook,
leaf_client_components: false,
}
}
}
Expand Down Expand Up @@ -172,10 +174,17 @@ impl TestAppBuilder {
|| (!queue.is_empty()
&& (queue.len() + remaining_modules) % (self.flatness + 1) == 0);
if leaf {
let maybe_use_client = if self.leaf_client_components {
r#""use client";"#
} else {
""
};
write_file(
&format!("leaf file {}", file.display()),
&file,
formatdoc! {r#"
{maybe_use_client}

{setup_imports}

{SETUP_EFFECT_PROPS}
Expand Down