Skip to content

Commit

Permalink
refactor: merge binding crates into rspack_binding_values (#8761)
Browse files Browse the repository at this point in the history
refactor: init
  • Loading branch information
h-a-n-a authored Dec 18, 2024
1 parent 27aed6f commit 8aeb507
Show file tree
Hide file tree
Showing 60 changed files with 134 additions and 187 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pnpm-lock.yaml
/crates/node_binding
/crates/rspack_ast_viewer
/crates/rspack_base64
/crates/rspack_binding_options
/crates/rspack_core
/crates/rspack_core/src/compiler/make @jerrykingxyz
/crates/rspack_error
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ jobs:
- name: Run test
# reason for excluding https://github.com/napi-rs/napi-rs/issues/2200
run: cargo test --workspace --exclude rspack_binding_options --exclude rspack_node -- --nocapture
run: cargo test --workspace --exclude rspack_node -- --nocapture

rust_test_miri:
name: Rust test miri
Expand Down Expand Up @@ -350,7 +350,7 @@ jobs:
env:
MIRIFLAGS: -Zmiri-tree-borrows -Zmiri-disable-isolation
# reason for excluding https://github.com/napi-rs/napi-rs/issues/2200
run: cargo miri test --workspace --exclude rspack_binding_options --exclude rspack_node -- --nocapture
run: cargo miri test --workspace --exclude rspack_node -- --nocapture

run_rust_benchmark:
name: Run rust benchmark
Expand Down
29 changes: 4 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ rspack_allocator = { version = "0.2.0", path = "crates/rsp
rspack_ast = { version = "0.2.0", path = "crates/rspack_ast" }
rspack_base64 = { version = "0.2.0", path = "crates/rspack_base64" }
rspack_binding = { version = "0.2.0", path = "crates/rspack_binding" }
rspack_binding_options = { version = "0.2.0", path = "crates/rspack_binding_options" }
rspack_binding_values = { version = "0.2.0", path = "crates/rspack_binding_values" }
rspack_builtin = { version = "0.2.0", path = "crates/rspack_builtin" }
rspack_cacheable = { version = "0.2.0", path = "crates/rspack_cacheable" }
Expand Down
4 changes: 1 addition & 3 deletions crates/node_binding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ version = "0.2.0"
crate-type = ["cdylib"]

[features]
default = []
plugin = ["rspack_binding_options/plugin"]
plugin = ["rspack_binding_values/plugin"]

[dependencies]
ropey = { workspace = true }
rspack_allocator = { workspace = true }
rspack_binding_options = { workspace = true }
rspack_binding_values = { workspace = true }
rspack_collections = { workspace = true }
rspack_core = { workspace = true }
Expand Down
4 changes: 1 addition & 3 deletions crates/node_binding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::sync::{Arc, Mutex};

use compiler::{Compiler, CompilerState, CompilerStateGuard};
use napi::bindgen_prelude::*;
use rspack_binding_options::BuiltinPlugin;
use rspack_core::{Compilation, PluginExt};
use rspack_error::Diagnostic;
use rspack_fs::IntermediateFileSystem;
Expand All @@ -25,7 +24,6 @@ mod resolver_factory;
pub use diagnostic::*;
use plugins::*;
use resolver_factory::*;
use rspack_binding_options::*;
use rspack_binding_values::*;
use rspack_tracing::chrome::FlushGuard;

Expand Down Expand Up @@ -84,7 +82,7 @@ impl Rspack {
compiler_path,
compiler_options,
plugins,
rspack_binding_options::buildtime_plugins::buildtime_plugins(),
rspack_binding_values::buildtime_plugins::buildtime_plugins(),
Some(Arc::new(NodeFileSystem::new(output_filesystem).map_err(
|e| Error::from_reason(format!("Failed to create writable filesystem: {e}",)),
)?)),
Expand Down
83 changes: 0 additions & 83 deletions crates/rspack_binding_options/Cargo.toml

This file was deleted.

22 changes: 0 additions & 22 deletions crates/rspack_binding_options/LICENSE

This file was deleted.

7 changes: 0 additions & 7 deletions crates/rspack_binding_options/src/lib.rs

This file was deleted.

95 changes: 79 additions & 16 deletions crates/rspack_binding_values/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,83 @@ license = "MIT"
name = "rspack_binding_values"
repository = "https://github.com/web-infra-dev/rspack"
version = "0.2.0"

[features]
plugin = ["rspack_loader_swc/plugin"]

[package.metadata.cargo-shear]
ignored = ["tracing"]

[dependencies]
cow-utils = { workspace = true }
futures = { workspace = true }
heck = { workspace = true }
napi = { workspace = true, features = ["async", "tokio_rt", "serde-json", "anyhow"] }
napi-derive = { workspace = true }
rspack_collections = { workspace = true }
rspack_core = { workspace = true }
rspack_error = { workspace = true }
rspack_napi = { workspace = true }
rspack_plugin_html = { workspace = true }
rspack_plugin_runtime = { workspace = true }
rspack_regex = { workspace = true }
rspack_util = { workspace = true }
rustc-hash = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
async-trait = { workspace = true }
cow-utils = { workspace = true }
derive_more = { workspace = true, features = ["debug"] }
futures = { workspace = true }
glob = { workspace = true }
heck = { workspace = true }
napi = { workspace = true, features = ["async", "tokio_rt", "serde-json", "anyhow"] }
napi-derive = { workspace = true }
pollster = { workspace = true }
rspack_cacheable = { workspace = true }
rspack_collections = { workspace = true }
rspack_core = { workspace = true }
rspack_error = { workspace = true }
rspack_hook = { workspace = true }
rspack_ids = { workspace = true }
rspack_napi = { workspace = true }
rspack_napi_macros = { workspace = true }
rspack_paths = { workspace = true }
rspack_regex = { workspace = true }
rspack_util = { workspace = true }
rustc-hash = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
swc_core = { workspace = true, default-features = false, features = ["ecma_transforms_react"] }
tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros", "test-util", "parking_lot"] }
tracing = { workspace = true }


rspack_loader_lightningcss = { workspace = true }
rspack_loader_preact_refresh = { workspace = true }
rspack_loader_react_refresh = { workspace = true }
rspack_loader_runner = { workspace = true }
rspack_loader_swc = { workspace = true }
rspack_loader_testing = { workspace = true }
rspack_plugin_asset = { workspace = true }
rspack_plugin_banner = { workspace = true }
rspack_plugin_context_replacement = { workspace = true }
rspack_plugin_copy = { workspace = true }
rspack_plugin_css = { workspace = true }
rspack_plugin_devtool = { workspace = true }
rspack_plugin_dll = { workspace = true }
rspack_plugin_dynamic_entry = { workspace = true }
rspack_plugin_ensure_chunk_conditions = { workspace = true }
rspack_plugin_entry = { workspace = true }
rspack_plugin_externals = { workspace = true }
rspack_plugin_extract_css = { workspace = true }
rspack_plugin_hmr = { workspace = true }
rspack_plugin_html = { workspace = true }
rspack_plugin_ignore = { workspace = true }
rspack_plugin_javascript = { workspace = true }
rspack_plugin_json = { workspace = true }
rspack_plugin_lazy_compilation = { workspace = true }
rspack_plugin_library = { workspace = true }
rspack_plugin_lightning_css_minimizer = { workspace = true }
rspack_plugin_limit_chunk_count = { workspace = true }
rspack_plugin_merge_duplicate_chunks = { workspace = true }
rspack_plugin_mf = { workspace = true }
rspack_plugin_no_emit_on_errors = { workspace = true }
rspack_plugin_progress = { workspace = true }
rspack_plugin_real_content_hash = { workspace = true }
rspack_plugin_remove_duplicate_modules = { workspace = true }
rspack_plugin_remove_empty_chunks = { workspace = true }
rspack_plugin_runtime = { workspace = true }
rspack_plugin_runtime_chunk = { workspace = true }
rspack_plugin_schemes = { workspace = true }
rspack_plugin_size_limits = { workspace = true }
rspack_plugin_split_chunks = { workspace = true }
rspack_plugin_swc_js_minimizer = { workspace = true }
rspack_plugin_warn_sensitive_module = { workspace = true }
rspack_plugin_wasm = { workspace = true }
rspack_plugin_web_worker_template = { workspace = true }
rspack_plugin_worker = { workspace = true }
7 changes: 7 additions & 0 deletions crates/rspack_binding_values/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![feature(let_chains)]
#![feature(try_blocks)]

mod asset;
mod asset_condition;
mod chunk;
Expand All @@ -19,6 +21,8 @@ mod module_graph;
mod normal_module_factory;
mod options;
mod path_data;
mod plugins;
mod raw_options;
mod resolver;
mod resource_data;
mod rspack_error;
Expand Down Expand Up @@ -46,6 +50,9 @@ pub use module_graph::*;
pub use normal_module_factory::*;
pub use options::*;
pub use path_data::*;
pub use plugins::buildtime_plugins;
pub(crate) use plugins::*;
pub use raw_options::*;
pub use resolver::*;
pub use resource_data::*;
pub use rspack_error::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ use std::collections::HashMap;

use napi::bindgen_prelude::*;
use napi_derive::napi;
use rspack_binding_values::{JsModuleWrapper, JsResourceData, JsRspackError};
use rspack_core::{LoaderContext, RunnerContext};
use rspack_error::error;
use rspack_loader_runner::{LoaderItem, State as LoaderState};
use rspack_napi::threadsafe_js_value_ref::ThreadsafeJsValueRef;

use crate::{JsModuleWrapper, JsResourceData, JsRspackError};

#[napi(object)]
pub struct JsLoaderItem {
pub request: String,
Expand Down
Loading

2 comments on commit 8aeb507

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-12-18 8a7084e) Current Change
10000_big_production-mode_disable-minimize + exec 37.9 s ± 525 ms 37.7 s ± 464 ms -0.44 %
10000_development-mode + exec 1.86 s ± 24 ms 1.89 s ± 27 ms +1.65 %
10000_development-mode_hmr + exec 683 ms ± 26 ms 679 ms ± 5.1 ms -0.63 %
10000_production-mode + exec 2.45 s ± 80 ms 2.42 s ± 33 ms -1.32 %
arco-pro_development-mode + exec 1.79 s ± 95 ms 1.77 s ± 64 ms -0.80 %
arco-pro_development-mode_hmr + exec 378 ms ± 1.1 ms 379 ms ± 1.2 ms +0.07 %
arco-pro_production-mode + exec 3.26 s ± 89 ms 3.27 s ± 95 ms +0.23 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.32 s ± 126 ms 3.32 s ± 82 ms +0.11 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.29 s ± 91 ms 3.29 s ± 108 ms -0.12 %
threejs_development-mode_10x + exec 1.64 s ± 20 ms 1.65 s ± 16 ms +0.58 %
threejs_development-mode_10x_hmr + exec 817 ms ± 17 ms 818 ms ± 30 ms +0.07 %
threejs_production-mode_10x + exec 5.4 s ± 134 ms 5.39 s ± 81 ms -0.12 %
10000_big_production-mode_disable-minimize + rss memory 9531 MiB ± 380 MiB 9530 MiB ± 281 MiB -0.01 %
10000_development-mode + rss memory 671 MiB ± 19.2 MiB 705 MiB ± 28.9 MiB +5.10 %
10000_development-mode_hmr + rss memory 1494 MiB ± 296 MiB 1533 MiB ± 272 MiB +2.59 %
10000_production-mode + rss memory 644 MiB ± 24.1 MiB 682 MiB ± 26.5 MiB +5.88 %
arco-pro_development-mode + rss memory 572 MiB ± 28.6 MiB 600 MiB ± 41.6 MiB +4.91 %
arco-pro_development-mode_hmr + rss memory 623 MiB ± 53.8 MiB 599 MiB ± 56.5 MiB -3.85 %
arco-pro_production-mode + rss memory 774 MiB ± 49.9 MiB 763 MiB ± 41.4 MiB -1.32 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 752 MiB ± 54.9 MiB 784 MiB ± 60.9 MiB +4.22 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 774 MiB ± 82.3 MiB 782 MiB ± 46.9 MiB +0.98 %
threejs_development-mode_10x + rss memory 654 MiB ± 29.2 MiB 682 MiB ± 36 MiB +4.31 %
threejs_development-mode_10x_hmr + rss memory 1203 MiB ± 127 MiB 1180 MiB ± 173 MiB -1.84 %
threejs_production-mode_10x + rss memory 971 MiB ± 66.9 MiB 950 MiB ± 63.1 MiB -2.22 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
_selftest ✅ success
rsdoctor ❌ failure
rspress ✅ success
rslib ✅ success
rsbuild ❌ failure
examples ❌ failure
devserver ✅ success
nuxt ✅ success

Please sign in to comment.