From ab8eb40b959cc29e160dc71454e70cce91849a06 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Tue, 28 Nov 2023 17:36:34 +0800 Subject: [PATCH 1/2] chore: push built-in plugins --- Cargo.lock | 1 + crates/binding_options/Cargo.toml | 1 + crates/binding_options/src/options/mod.rs | 10 ++++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e00f98a..96c90fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,6 +284,7 @@ dependencies = [ "napi", "napi-derive", "plugin_manifest", + "plugin_specilize_module_name", "rspack_binding_macros", "rspack_binding_options", "rspack_binding_values", diff --git a/crates/binding_options/Cargo.toml b/crates/binding_options/Cargo.toml index a0a45e8..57632ca 100644 --- a/crates/binding_options/Cargo.toml +++ b/crates/binding_options/Cargo.toml @@ -48,6 +48,7 @@ rspack_hash = { path = "../.rspack_crates/rspack_has rspack_swc_visitors = { path = "../.rspack_crates/rspack_swc_visitors" } loader_compilation = { path = "../loader_compilation" } plugin_manifest = { path = "../plugin_manifest" } +plugin_specilize_module_name = { path = "../plugin_specilize_module_name" } futures-util = { workspace = true } anyhow = { workspace = true, features = ["backtrace"] } diff --git a/crates/binding_options/src/options/mod.rs b/crates/binding_options/src/options/mod.rs index 9fe4d0e..4830f15 100644 --- a/crates/binding_options/src/options/mod.rs +++ b/crates/binding_options/src/options/mod.rs @@ -10,8 +10,8 @@ use serde::Deserialize; use rspack_binding_options::{ RawBuiltins, RawCacheOptions, RawContext, RawDevServer, RawDevtool, RawExperiments, - RawMode, RawNodeOption, RawOutputOptions, RawResolveOptions, RawOptimizationOptions, - RawSnapshotOptions, RawStatsOptions, RawTarget, RawModuleOptions, RawOptionsApply, + RawMode, RawNodeOption, RawOutputOptions, RawResolveOptions, RawSnapshotOptions, + RawStatsOptions, RawTarget, RawModuleOptions, RawOptionsApply, }; mod raw_module; @@ -164,6 +164,12 @@ impl RawOptionsApply for RSPackRawOptions { plugins.push(rspack_plugin_warn_sensitive_module::WarnCaseSensitiveModulesPlugin.boxed()); + // Add custom plugins. + plugins.push(plugin_manifest::ManifestPlugin::new().boxed()); + plugins.push(plugin_specilize_module_name::SpecilizeModuleNamePlugin::new( + Some(vec!["universal-env".to_string(), "@uni/env".to_string()]) + ).boxed()); + Ok(Self::Options { context, mode, From 294b23957859c4fccd84bbf3f32fb4806eefb503 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Thu, 30 Nov 2023 14:09:09 +0800 Subject: [PATCH 2/2] chore: add default plugin --- Cargo.lock | 1 - crates/binding_options/Cargo.toml | 2 +- crates/binding_options/src/options/mod.rs | 3 --- crates/plugin_manifest/src/plugin.rs | 7 +------ 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cede8f0..ba40dc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,7 +284,6 @@ dependencies = [ "napi", "napi-derive", "plugin_manifest", - "plugin_specilize_module_name", "rspack_binding_macros", "rspack_binding_options", "rspack_binding_values", diff --git a/crates/binding_options/Cargo.toml b/crates/binding_options/Cargo.toml index 57632ca..5163393 100644 --- a/crates/binding_options/Cargo.toml +++ b/crates/binding_options/Cargo.toml @@ -48,7 +48,7 @@ rspack_hash = { path = "../.rspack_crates/rspack_has rspack_swc_visitors = { path = "../.rspack_crates/rspack_swc_visitors" } loader_compilation = { path = "../loader_compilation" } plugin_manifest = { path = "../plugin_manifest" } -plugin_specilize_module_name = { path = "../plugin_specilize_module_name" } +## plugin_specilize_module_name = { path = "../plugin_specilize_module_name" } futures-util = { workspace = true } anyhow = { workspace = true, features = ["backtrace"] } diff --git a/crates/binding_options/src/options/mod.rs b/crates/binding_options/src/options/mod.rs index dd3d747..b7b24d4 100644 --- a/crates/binding_options/src/options/mod.rs +++ b/crates/binding_options/src/options/mod.rs @@ -166,9 +166,6 @@ impl RawOptionsApply for RSPackRawOptions { // Add custom plugins. plugins.push(plugin_manifest::ManifestPlugin::new().boxed()); - plugins.push(plugin_specilize_module_name::SpecilizeModuleNamePlugin::new( - Some(vec!["universal-env".to_string(), "@uni/env".to_string()]) - ).boxed()); Ok(Self::Options { context, diff --git a/crates/plugin_manifest/src/plugin.rs b/crates/plugin_manifest/src/plugin.rs index 8bbde27..c2e6cab 100644 --- a/crates/plugin_manifest/src/plugin.rs +++ b/crates/plugin_manifest/src/plugin.rs @@ -91,13 +91,8 @@ impl Plugin for ManifestPlugin { } }); let json_string = serde_json::to_string(&assets_mainfest).unwrap(); - let output_path = compilation - .options - .output - .path - .join("assets-manifest.json".to_string()).to_string_lossy().to_string(); compilation.emit_asset( - output_path, + "assets-manifest.json".to_string(), CompilationAsset::from(RawSource::from(json_string).boxed()), ); Ok(())