Skip to content

Commit ec52b1c

Browse files
committed
fix: fixed hsr in deployment
1 parent 1936b62 commit ec52b1c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/perseus-macro/src/template_rx.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub fn get_live_reload_frag() -> TokenStream {
106106
::perseus::state::hsr_freeze(render_ctx).await;
107107
};
108108
#[cfg(not(all(feature = "hsr", debug_assertions)))]
109+
#[allow(unused_variables)]
109110
let hsr_frag = quote!();
110111

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

140-
/// Gets the code fragment used to support HSR thawing.
141+
/// Gets the code fragment used to support HSR thawing. This MUST be prefixed by a `#[cfg(target_arch = "wasm32")]`.
141142
pub fn get_hsr_thaw_frag() -> TokenStream {
142143
#[cfg(all(feature = "hsr", debug_assertions))]
143144
let hsr_thaw_frag = quote! {{
@@ -152,8 +153,9 @@ pub fn get_hsr_thaw_frag() -> TokenStream {
152153
}
153154
}));
154155
}};
156+
// 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!)
155157
#[cfg(not(all(feature = "hsr", debug_assertions)))]
156-
let hsr_thaw_frag = quote!();
158+
let hsr_thaw_frag = quote!({});
157159

158160
hsr_thaw_frag
159161
}

packages/perseus/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ js-sys = { version = "0.3", optional = true }
4040

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

0 commit comments

Comments
 (0)