Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: apply correct top level mode to worker loader script #642

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/pipelines/rust/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,16 @@ impl RustApp {
"copying {js_loader_path} to {}",
js_loader_path_dist.display()
);
self.copy_or_minify_js(js_loader_path, &js_loader_path_dist)
.await
.context("error minifying or copying JS loader file to stage dir")?;
self.copy_or_minify_js(
js_loader_path,
&js_loader_path_dist,
match self.wasm_bindgen_target {
WasmBindgenTarget::NoModules => TopLevelMode::Global,
_ => TopLevelMode::Module,
},
)
.await
.context("error minifying or copying JS loader file to stage dir")?;

tracing::debug!("copying {wasm_path} to {}", wasm_path_dist.display());

Expand Down Expand Up @@ -664,6 +671,7 @@ impl RustApp {
&self,
origin_path: Utf8PathBuf,
destination_path: &Path,
mode: TopLevelMode,
) -> Result<()> {
let bytes = fs::read(origin_path)
.await
Expand All @@ -674,7 +682,7 @@ impl RustApp {
let mut output: Vec<u8> = vec![];
let bytes_clone = bytes.clone();
let session = minify_js::Session::new();
let res = minify_js::minify(&session, TopLevelMode::Module, &bytes, &mut output);
let res = minify_js::minify(&session, mode, &bytes, &mut output);
if res.is_err() {
output = bytes_clone;
}
Expand Down