Skip to content

Commit

Permalink
feat: throw error for outdated compilation (#8315)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind authored Nov 5, 2024
1 parent 0242d74 commit 0763068
Show file tree
Hide file tree
Showing 9 changed files with 359 additions and 232 deletions.
12 changes: 6 additions & 6 deletions crates/rspack_binding_values/src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,31 @@ fn chunk(ukey: u32, compilation: &Compilation) -> &Chunk {

#[napi(js_name = "__chunk_inner_is_only_initial")]
pub fn is_only_initial(js_chunk_ukey: u32, js_compilation: &JsCompilation) -> bool {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let chunk = chunk(js_chunk_ukey, compilation);
chunk.is_only_initial(&compilation.chunk_group_by_ukey)
}

#[napi(js_name = "__chunk_inner_can_be_initial")]
pub fn can_be_initial(js_chunk_ukey: u32, js_compilation: &JsCompilation) -> bool {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let chunk = chunk(js_chunk_ukey, compilation);
chunk.can_be_initial(&compilation.chunk_group_by_ukey)
}

#[napi(js_name = "__chunk_inner_has_runtime")]
pub fn has_runtime(js_chunk_ukey: u32, js_compilation: &JsCompilation) -> bool {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let chunk = chunk(js_chunk_ukey, compilation);
chunk.has_runtime(&compilation.chunk_group_by_ukey)
}

#[napi(js_name = "__chunk_inner_get_all_async_chunks")]
pub fn get_all_async_chunks(js_chunk_ukey: u32, js_compilation: &JsCompilation) -> Vec<JsChunk> {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let chunk = chunk(js_chunk_ukey, compilation);
chunk
Expand All @@ -128,7 +128,7 @@ pub fn get_all_async_chunks(js_chunk_ukey: u32, js_compilation: &JsCompilation)

#[napi(js_name = "__chunk_inner_get_all_initial_chunks")]
pub fn get_all_initial_chunks(js_chunk_ukey: u32, js_compilation: &JsCompilation) -> Vec<JsChunk> {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let chunk = chunk(js_chunk_ukey, compilation);
chunk
Expand All @@ -143,7 +143,7 @@ pub fn get_all_referenced_chunks(
js_chunk_ukey: u32,
js_compilation: &JsCompilation,
) -> Vec<JsChunk> {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let chunk = chunk(js_chunk_ukey, compilation);
chunk
Expand Down
8 changes: 4 additions & 4 deletions crates/rspack_binding_values/src/chunk_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn get_chunk_modules(
js_chunk_ukey: u32,
js_compilation: &JsCompilation,
) -> Vec<JsModuleWrapper> {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let module_graph = compilation.get_module_graph();
let modules = compilation
Expand All @@ -33,7 +33,7 @@ pub fn get_chunk_entry_modules(
js_chunk_ukey: u32,
js_compilation: &JsCompilation,
) -> Vec<JsModuleWrapper> {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let modules = compilation
.chunk_graph
Expand All @@ -51,7 +51,7 @@ pub fn get_chunk_entry_dependent_chunks_iterable(
js_chunk_ukey: u32,
js_compilation: &JsCompilation,
) -> Vec<JsChunk> {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let chunks = compilation
.chunk_graph
Expand All @@ -76,7 +76,7 @@ pub fn get_chunk_modules_iterable_by_source_type(
source_type: String,
js_compilation: &JsCompilation,
) -> Result<Vec<JsModuleWrapper>> {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

Ok(
compilation
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_binding_values/src/chunk_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ fn chunk_group(ukey: u32, compilation: &Compilation) -> &ChunkGroup {

#[napi(js_name = "__chunk_group_inner_get_chunk_group")]
pub fn get_chunk_group(ukey: u32, js_compilation: &JsCompilation) -> JsChunkGroup {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let cg = chunk_group(ukey, compilation);
JsChunkGroup::from_chunk_group(cg, compilation)
}

#[napi(js_name = "__entrypoint_inner_get_runtime_chunk")]
pub fn get_runtime_chunk(ukey: u32, js_compilation: &JsCompilation) -> JsChunk {
let compilation = unsafe { js_compilation.0.as_ref() };
let compilation = unsafe { js_compilation.inner.as_ref() };

let entrypoint = chunk_group(ukey, compilation);
let chunk_ukey = entrypoint.get_runtime_chunk(&compilation.chunk_group_by_ukey);
Expand Down
Loading

2 comments on commit 0763068

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
_selftest ✅ success
rspress ✅ success
rslib ✅ success
rsbuild ❌ failure
examples ❌ failure
devserver ✅ success

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-11-05 9c56263) Current Change
10000_big_production-mode + exec 43.9 s ± 638 ms 43.8 s ± 1.17 s -0.12 %
10000_development-mode + exec 1.83 s ± 22 ms 1.83 s ± 18 ms -0.08 %
10000_development-mode_hmr + exec 644 ms ± 4.4 ms 648 ms ± 15 ms +0.62 %
10000_production-mode + exec 2.41 s ± 19 ms 2.42 s ± 22 ms +0.50 %
arco-pro_development-mode + exec 1.75 s ± 55 ms 1.79 s ± 68 ms +2.32 %
arco-pro_development-mode_hmr + exec 430 ms ± 1.5 ms 431 ms ± 1.6 ms +0.09 %
arco-pro_production-mode + exec 3.21 s ± 75 ms 3.23 s ± 87 ms +0.61 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.24 s ± 57 ms 3.26 s ± 62 ms +0.75 %
threejs_development-mode_10x + exec 1.58 s ± 7.7 ms 1.57 s ± 16 ms -0.31 %
threejs_development-mode_10x_hmr + exec 771 ms ± 19 ms 777 ms ± 16 ms +0.80 %
threejs_production-mode_10x + exec 4.95 s ± 27 ms 4.94 s ± 22 ms -0.10 %

Please sign in to comment.