Skip to content

Commit

Permalink
fix: 🐛 adjust chunk cache key for edge case (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
stormslowly authored Dec 13, 2023
1 parent 96c6550 commit 057da4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions crates/mako/src/chunk_pot/ast_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ use crate::transform_in_generate::transform_css_generate;

#[cached(
result = true,
key = "u64",
convert = "{chunk_pot.stylesheet.as_ref().unwrap().raw_hash}"
type = "SizedCache<String , ChunkFile>",
create = "{ SizedCache::with_size(500) }",
key = "String",
convert = r#"{format!("{}.{:x}",chunk_pot.chunk_id,chunk_pot.stylesheet.as_ref().unwrap().raw_hash)}"#
)]
pub(crate) fn render_css_chunk(chunk_pot: &ChunkPot, context: &Arc<Context>) -> Result<ChunkFile> {
mako_core::mako_profile_function!(&chunk_pot.js_name);
Expand Down Expand Up @@ -94,10 +96,10 @@ pub(crate) fn render_css_chunk(chunk_pot: &ChunkPot, context: &Arc<Context>) ->

#[cached(
result = true,
type = "SizedCache<u64 , ChunkFile>",
type = "SizedCache<String , ChunkFile>",
create = "{ SizedCache::with_size(500) }",
key = "u64",
convert = "{chunk_pot.js_hash}"
key = "String",
convert = r#"{format!("{}.{:x}", chunk_pot.chunk_id, chunk_pot.js_hash)}"#
)]
pub(crate) fn render_normal_js_chunk(
chunk_pot: &ChunkPot,
Expand Down
6 changes: 3 additions & 3 deletions crates/mako/src/chunk_pot/str_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ pub(super) fn render_entry_js_chunk(

#[cached(
result = true,
type = "SizedCache<u64 , ChunkFile>",
type = "SizedCache<String , ChunkFile>",
create = "{ SizedCache::with_size(500) }",
key = "u64",
convert = "{chunk_pot.js_hash}"
key = "String",
convert = r#"{format!("{}.{:x}", chunk_pot.chunk_id, chunk_pot.js_hash)}"#
)]
pub(super) fn render_normal_js_chunk(
chunk_pot: &ChunkPot,
Expand Down

0 comments on commit 057da4b

Please sign in to comment.