Skip to content

Commit

Permalink
chore: fix sort
Browse files Browse the repository at this point in the history
  • Loading branch information
hardfist committed Jan 29, 2025
1 parent d571476 commit 03f7f9f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/rspack_plugin_next_flight_client_entry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod is_metadata_route;
mod loader_util;

use std::{
cmp::Ordering,
mem,
ops::DerefMut,
path::Path,
Expand Down Expand Up @@ -642,10 +643,12 @@ impl FlightClientEntryPlugin {
.collect();

modules.sort_unstable_by(|a, b| {
if REGEX_CSS.is_match(&b.0) {
std::cmp::Ordering::Greater
} else {
a.0.cmp(&b.0)
let a_is_css = REGEX_CSS.is_match(&a.0);
let b_is_css = REGEX_CSS.is_match(&b.0);
match ((a_is_css, b_is_css)) {
(false, true) => Ordering::Less,
(true, false) => Ordering::Greater,
(_, _) => a.0.cmp(&b.0),
}
});

Expand Down
14 changes: 14 additions & 0 deletions examples/rspack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
context: __dirname,
entry: {
main: './src/index.js'
},
plugins: [{
apply(compiler) {
compiler.hooks.emit.tap({ name: 'MyPlugin', stage: 0 }, compilation => {
console.log('This is an example plugin!');
})

}
}]
}
Empty file added examples/src/index.js
Empty file.

0 comments on commit 03f7f9f

Please sign in to comment.