Skip to content

Commit

Permalink
chore: 删除多余的.wasm load逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
YufJi committed Jan 17, 2025
1 parent d9c513d commit 6b37ba9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
22 changes: 0 additions & 22 deletions crates/mako/src/build/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const CSS_EXTENSIONS: [&str; 1] = ["css"];
const JSON_EXTENSIONS: [&str; 2] = ["json", "json5"];
const YAML_EXTENSIONS: [&str; 2] = ["yaml", "yml"];
const XML_EXTENSIONS: [&str; 1] = ["xml"];
const WASM_EXTENSIONS: [&str; 1] = ["wasm"];
const TOML_EXTENSIONS: [&str; 1] = ["toml"];
const SVG_EXTENSIONS: [&str; 1] = ["svg"];
const MD_EXTENSIONS: [&str; 2] = ["md", "mdx"];
Expand Down Expand Up @@ -180,27 +179,6 @@ export function moduleToDom(css) {
}));
}

// wasm
if WASM_EXTENSIONS.contains(&file.extname.as_str()) {
let final_file_name = format!(
"{}.{}.{}",
file.get_file_stem(),
file.get_content_hash()?,
file.extname
);
context.emit_assets(
file.pathname.to_string_lossy().to_string(),
final_file_name.clone(),
);
return Ok(Content::Js(JsContent {
content: format!(
"module.exports = require._interopreRequireWasm(exports, \"{}\")",
final_file_name
),
..Default::default()
}));
}

// xml
if XML_EXTENSIONS.contains(&file.extname.as_str()) {
let content = FileSystem::read_file(&file.pathname)?;
Expand Down
5 changes: 4 additions & 1 deletion crates/mako/src/plugins/wasm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use crate::plugin::{Plugin, PluginLoadParam};

pub struct WasmRuntimePlugin {}

const WASM_EXTENSIONS: [&str; 1] = ["wasm"];

impl Plugin for WasmRuntimePlugin {
fn name(&self) -> &str {
"wasm_runtime"
Expand Down Expand Up @@ -39,7 +41,8 @@ impl Plugin for WasmRuntimePlugin {
_context: &Arc<Context>,
) -> anyhow::Result<Option<Content>> {
let file = param.file;
if file.path.to_string_lossy().ends_with(".wasm") {

if WASM_EXTENSIONS.contains(&file.extname.as_str()) {
let final_file_name = format!(
"{}.{}.{}",
file.get_file_stem(),
Expand Down

0 comments on commit 6b37ba9

Please sign in to comment.