Skip to content

Commit

Permalink
fix: fixed hsr in deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
arctic-hen7 committed Jan 29, 2022
1 parent 1936b62 commit ec52b1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/perseus-macro/src/template_rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub fn get_live_reload_frag() -> TokenStream {
::perseus::state::hsr_freeze(render_ctx).await;
};
#[cfg(not(all(feature = "hsr", debug_assertions)))]
#[allow(unused_variables)]
let hsr_frag = quote!();

#[cfg(all(feature = "live-reload", debug_assertions))]
Expand Down Expand Up @@ -137,7 +138,7 @@ pub fn get_live_reload_frag() -> TokenStream {
live_reload_frag
}

/// Gets the code fragment used to support HSR thawing.
/// Gets the code fragment used to support HSR thawing. This MUST be prefixed by a `#[cfg(target_arch = "wasm32")]`.
pub fn get_hsr_thaw_frag() -> TokenStream {
#[cfg(all(feature = "hsr", debug_assertions))]
let hsr_thaw_frag = quote! {{
Expand All @@ -152,8 +153,9 @@ pub fn get_hsr_thaw_frag() -> TokenStream {
}
}));
}};
// If HSR is disabled, there'll still be a Wasm-gate, which means we have to give it something to gate (or it'll gate the code after it, which is very bad!)
#[cfg(not(all(feature = "hsr", debug_assertions)))]
let hsr_thaw_frag = quote!();
let hsr_thaw_frag = quote!({});

hsr_thaw_frag
}
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ js-sys = { version = "0.3", optional = true }

[features]
# Live reloading will only take effect in development, and won't impact production
# BUG This adds 400B to the production bundle (that's without size optimizations though)
# BUG This adds 1.9kB to the production bundle (that's without size optimizations though)
default = [ "live-reload", "hsr" ]
translator-fluent = ["fluent-bundle", "unic-langid", "intl-memoizer"]
# This feature makes tinker-only plugins be registered (this flag is enabled internally in the engine)
Expand Down

0 comments on commit ec52b1c

Please sign in to comment.