diff --git a/CHANGELOG_zh-CN.md b/CHANGELOG_zh-CN.md index 794ed7b24..05917c72c 100644 --- a/CHANGELOG_zh-CN.md +++ b/CHANGELOG_zh-CN.md @@ -407,7 +407,7 @@ `2024-06-26` - 改进 module concatenate 实现,合并后的模块仍然支持 Shared Reference by [@stormslowly](https://github.com/stormslowly) in [#1295](https://github.com/umijs/mako/pull/1295) -- 修复 hmr http 响应未设置 content-typ 导致乱码问题 by [@whyer11](https://github.com/whyer11) in [#1307](https://github.com/umijs/mako/pull/1307) +- 修复 hmr http 响应未设置 content-type 导致乱码问题 by [@whyer11](https://github.com/whyer11) in [#1307](https://github.com/umijs/mako/pull/1307) ## 0.7.1 diff --git a/crates/binding/src/js_plugin.rs b/crates/binding/src/js_plugin.rs index 4bfaec8de..cf63fb590 100644 --- a/crates/binding/src/js_plugin.rs +++ b/crates/binding/src/js_plugin.rs @@ -257,38 +257,31 @@ impl Plugin for JsPlugin { fn before_rebuild(&self, paths: Vec) -> Result> { // TODO: 临时方案,出于热更性能考虑只在less/sass文件变动时调用js-hook,后续优化。 - let mut has_less_or_sass = false; - for path in &paths { - if path - .extension() - .map(|ext| ext == "less" || ext == "scss") - .unwrap_or(false) - { - has_less_or_sass = true; - break; - } - } - if !has_less_or_sass { - return Ok(paths); - } - - if let Some(hook) = &self.hooks.before_rebuild { - let result: Option> = match hook.call(( - (), - paths - .iter() - .map(|p| p.to_string_lossy().to_string()) - .collect(), - )) { - Ok(res) => res, - Err(_) => return Ok(paths), - }; - - if let Some(result) = result { - return Ok(result.iter().map(PathBuf::from).collect()); - } - } - - Ok(paths) + let (less_or_sass, others): (Vec, Vec) = paths + .into_iter() + .partition(|p| p.extension().is_some_and(|p| p == "less" || p == "sass")); + Ok([ + match &self.hooks.before_rebuild { + Some(hook) => { + match hook.call(( + (), + less_or_sass + .iter() + .map(|p| p.to_string_lossy().to_string()) + .collect(), + )) { + Ok(paths) => paths.map_or(less_or_sass, |paths| { + paths.iter().map(PathBuf::from).collect() + }), + Err(_) => less_or_sass, + } + } + None => less_or_sass, + }, + others, + ] + .into_iter() + .flatten() + .collect()) } } diff --git a/e2e/fixtures/javascript.typescript/src/ts-advanced.ts b/e2e/fixtures/javascript.typescript/src/ts-advanced.ts index 0beb27bd7..660d3f261 100644 --- a/e2e/fixtures/javascript.typescript/src/ts-advanced.ts +++ b/e2e/fixtures/javascript.typescript/src/ts-advanced.ts @@ -116,7 +116,7 @@ type example = NonNullable; // Parameters & ReturnType type IFoo = ( uname: string, - uage: number + usage: number ) => { name: string; age: number; @@ -124,7 +124,7 @@ type IFoo = ( //参数类型 type Ibar = Parameters; -// type Ibar = [uname: string, uage: number] +// type Ibar = [uname: string, usage: number] type T_RT = ReturnType; // type T_RT = { diff --git a/e2e/fixtures/module-federation.producer/expect.js b/e2e/fixtures/module-federation.producer/expect.js index ab5ff0183..4f6e793cb 100644 --- a/e2e/fixtures/module-federation.producer/expect.js +++ b/e2e/fixtures/module-federation.producer/expect.js @@ -6,7 +6,7 @@ const manifest = JSON.parse(files["mf-manifest.json"]); assert( manifest.metaData.remoteEntry.name === 'remoteEntry.js', - "should generate mf contanier entry" + "should generate mf container entry" ) assert(