From 82f6a2497c03a341ceb0447cb652cb309a75eee1 Mon Sep 17 00:00:00 2001 From: Hana Date: Mon, 9 Dec 2024 20:23:39 +0800 Subject: [PATCH] perf: init --- Cargo.lock | 64 ++++++++++++++++++++++- Cargo.toml | 2 +- crates/rspack_binding_values/src/stats.rs | 5 +- 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac54874d177..a9939e61a85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,6 +61,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + [[package]] name = "allocator-api2" version = "0.2.15" @@ -1860,6 +1866,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -2314,6 +2326,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.13.0" @@ -2975,6 +2996,31 @@ version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" +[[package]] +name = "ouroboros" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "944fa20996a25aded6b4795c6d63f10014a7a83f8be9828a11860b08c5fc4a67" +dependencies = [ + "aliasable", + "ouroboros_macro", + "static_assertions", +] + +[[package]] +name = "ouroboros_macro" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39b0deead1528fd0e5947a8546a9642a9777c25f6e1e26f34c97b204bbb465bd" +dependencies = [ + "heck 0.4.1", + "itertools 0.12.1", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.90", +] + [[package]] name = "outref" version = "0.1.0" @@ -3348,6 +3394,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", + "version_check", + "yansi", +] + [[package]] name = "prost" version = "0.13.3" @@ -4943,12 +5002,13 @@ dependencies = [ [[package]] name = "rspack_sources" version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d52f5aa6afd8cc49a3e3f796a00918d11d97ed5043d0881165d8fc1aca1ae8c" +source = "git+https://github.com/web-infra-dev/rspack-sources?rev=ea8176949b63de0e61f6e6c27b816f779267d3de#ea8176949b63de0e61f6e6c27b816f779267d3de" dependencies = [ "dashmap 5.5.3", "dyn-clone", + "itertools 0.13.0", "memchr", + "ouroboros", "rustc-hash 1.1.0", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 23dd2f61238..94b8cc9fb05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,7 @@ rayon = { version = "1.10.0" } regex = { version = "1.11.1" } ropey = "1.6.1" rspack_resolver = { version = "0.3.5", features = ["package_json_raw_json_api"] } -rspack_sources = { version = "=0.3.6" } +rspack_sources = { git = "https://github.com/web-infra-dev/rspack-sources", rev = "ea8176949b63de0e61f6e6c27b816f779267d3de" } rustc-hash = { version = "2.1.0" } serde = { version = "1.0.215" } serde_json = { version = "1.0.133" } diff --git a/crates/rspack_binding_values/src/stats.rs b/crates/rspack_binding_values/src/stats.rs index b1ac4a3c6e5..8cfdf4b55bb 100644 --- a/crates/rspack_binding_values/src/stats.rs +++ b/crates/rspack_binding_values/src/stats.rs @@ -3,7 +3,7 @@ use std::cell::RefCell; use napi_derive::napi; use rspack_collections::Identifier; use rspack_core::{ - rspack_sources::{RawSource, Source}, + rspack_sources::{RawBufferSource, RawSource, Source}, EntrypointsStatsOption, ExtendedStatsOptions, Stats, StatsChunk, StatsModule, StatsUsedExports, }; use rspack_napi::{ @@ -503,6 +503,9 @@ impl TryFrom> for JsStatsModule { fn try_from(stats: StatsModule) -> std::result::Result { let source = stats.source.map(|source| { + if let Some(raw_source) = source.as_any().downcast_ref::() { + return JsStatsModuleSource::B(Buffer::from(raw_source.buffer().to_vec())); + } if let Some(raw_source) = source.as_any().downcast_ref::() { if raw_source.is_buffer() { return JsStatsModuleSource::B(Buffer::from(raw_source.buffer().to_vec()));