Skip to content

Commit e237005

Browse files
committed
add test cases
1 parent 56e2634 commit e237005

File tree

106 files changed

+628
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+628
-64
lines changed

turbopack/crates/turbopack-tests/tests/execution.rs

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ struct TestOptions {
242242
scope_hoisting: Option<bool>,
243243
#[serde(default)]
244244
minify: bool,
245+
#[serde(default)]
246+
production_chunking: bool,
245247
}
246248

247249
fn default_tree_shaking_mode() -> Option<TreeShakingMode> {
@@ -255,6 +257,7 @@ impl Default for TestOptions {
255257
remove_unused_exports: None,
256258
scope_hoisting: None,
257259
minify: false,
260+
production_chunking: false,
258261
}
259262
}
260263
}
@@ -470,7 +473,7 @@ async fn run_test_operation(prepared_test: ResolvedVc<PreparedTest>) -> Result<V
470473
false,
471474
);
472475

473-
let chunking_context = NodeJsChunkingContext::builder(
476+
let mut builder = NodeJsChunkingContext::builder(
474477
project_root.clone(),
475478
chunk_root_path.clone(),
476479
chunk_root_path_in_root_path_offset,
@@ -480,20 +483,6 @@ async fn run_test_operation(prepared_test: ResolvedVc<PreparedTest>) -> Result<V
480483
env,
481484
RuntimeType::Development,
482485
)
483-
.chunking_config(
484-
Vc::<EcmascriptChunkType>::default().to_resolved().await?,
485-
ChunkingConfig {
486-
min_chunk_size: 10_000,
487-
..Default::default()
488-
},
489-
)
490-
.chunking_config(
491-
Vc::<CssChunkType>::default().to_resolved().await?,
492-
ChunkingConfig {
493-
max_merge_chunk_size: 100_000,
494-
..Default::default()
495-
},
496-
)
497486
.module_merging(options.scope_hoisting.unwrap_or(true))
498487
.minify_type(if options.minify {
499488
MinifyType::Minify {
@@ -510,8 +499,28 @@ async fn run_test_operation(prepared_test: ResolvedVc<PreparedTest>) -> Result<V
510499
)
511500
} else {
512501
None
513-
})
514-
.build();
502+
});
503+
if options.production_chunking {
504+
builder = builder
505+
.chunking_config(
506+
Vc::<EcmascriptChunkType>::default().to_resolved().await?,
507+
ChunkingConfig {
508+
min_chunk_size: 2_000,
509+
max_chunk_count_per_group: 40,
510+
max_merge_chunk_size: 200_000,
511+
..Default::default()
512+
},
513+
)
514+
.chunking_config(
515+
Vc::<CssChunkType>::default().to_resolved().await?,
516+
ChunkingConfig {
517+
max_merge_chunk_size: 100_000,
518+
..Default::default()
519+
},
520+
)
521+
.nested_async_availability(true);
522+
}
523+
let chunking_context = builder.build();
515524

516525
let res = evaluate(
517526
jest_entry_asset,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
async function all() {
2+
await import('./b0.js')
3+
await import('./b1.js')
4+
await import('./b2.js')
5+
await import('./b3.js')
6+
await import('./b4.js')
7+
await import('./b5.js')
8+
await import('./b6.js')
9+
await import('./b7.js')
10+
await import('./b8.js')
11+
await import('./b9.js')
12+
}
13+
14+
await all()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
async function all() {
2+
await import('./b0.js')
3+
await import('./b1.js')
4+
await import('./b2.js')
5+
await import('./b3.js')
6+
await import('./b4.js')
7+
await import('./b5.js')
8+
await import('./b6.js')
9+
await import('./b7.js')
10+
await import('./b8.js')
11+
await import('./b9.js')
12+
}
13+
14+
await all()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
async function all() {
2+
await import('./b0.js')
3+
await import('./b1.js')
4+
await import('./b2.js')
5+
await import('./b3.js')
6+
await import('./b4.js')
7+
await import('./b5.js')
8+
await import('./b6.js')
9+
await import('./b7.js')
10+
await import('./b8.js')
11+
await import('./b9.js')
12+
}
13+
14+
await all()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
async function all() {
2+
await import('./b0.js')
3+
await import('./b1.js')
4+
await import('./b2.js')
5+
await import('./b3.js')
6+
await import('./b4.js')
7+
await import('./b5.js')
8+
await import('./b6.js')
9+
await import('./b7.js')
10+
await import('./b8.js')
11+
await import('./b9.js')
12+
}
13+
14+
await all()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
async function all() {
2+
await import('./b0.js')
3+
await import('./b1.js')
4+
await import('./b2.js')
5+
await import('./b3.js')
6+
await import('./b4.js')
7+
await import('./b5.js')
8+
await import('./b6.js')
9+
await import('./b7.js')
10+
await import('./b8.js')
11+
await import('./b9.js')
12+
}
13+
14+
await all()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
async function all() {
2+
await import('./b0.js')
3+
await import('./b1.js')
4+
await import('./b2.js')
5+
await import('./b3.js')
6+
await import('./b4.js')
7+
await import('./b5.js')
8+
await import('./b6.js')
9+
await import('./b7.js')
10+
await import('./b8.js')
11+
await import('./b9.js')
12+
}
13+
14+
await all()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
async function all() {
2+
await import('./b0.js')
3+
await import('./b1.js')
4+
await import('./b2.js')
5+
await import('./b3.js')
6+
await import('./b4.js')
7+
await import('./b5.js')
8+
await import('./b6.js')
9+
await import('./b7.js')
10+
await import('./b8.js')
11+
await import('./b9.js')
12+
}
13+
14+
await all()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
async function all() {
2+
await import('./b0.js')
3+
await import('./b1.js')
4+
await import('./b2.js')
5+
await import('./b3.js')
6+
await import('./b4.js')
7+
await import('./b5.js')
8+
await import('./b6.js')
9+
await import('./b7.js')
10+
await import('./b8.js')
11+
await import('./b9.js')
12+
}
13+
14+
await all()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
async function all() {
2+
await import('./b0.js')
3+
await import('./b1.js')
4+
await import('./b2.js')
5+
await import('./b3.js')
6+
await import('./b4.js')
7+
await import('./b5.js')
8+
await import('./b6.js')
9+
await import('./b7.js')
10+
await import('./b8.js')
11+
await import('./b9.js')
12+
}
13+
14+
await all()

0 commit comments

Comments
 (0)