From 5afb21b8d8bc65479446618256ae6c7144cd6eba Mon Sep 17 00:00:00 2001 From: Gengkun Date: Mon, 27 Nov 2023 14:41:26 +0800 Subject: [PATCH] feat: Module Federation, part 3, ProvideSharedPlugin (#4778) * ok * fix * fix --- .../src/options/raw_builtins/mod.rs | 10 +++ .../src/options/raw_builtins/raw_mf.rs | 20 +++++ .../src/build_chunk_graph/code_splitter.rs | 3 + .../src/dependency/dependency_type.rs | 6 ++ .../src/dependency/runtime_template.rs | 4 + crates/rspack_core/src/lib.rs | 8 ++ crates/rspack_core/src/mf/sharing/mod.rs | 3 + .../src/mf/sharing/provide_shared_module.rs | 23 ++++++ .../src/mf/sharing/provide_shared_plugin.rs | 19 +++++ .../rspack_core/src/normal_module_factory.rs | 3 + crates/rspack_core/src/plugin/args.rs | 3 + packages/rspack/src/builtin-plugin/base.ts | 5 ++ .../src/container/ModuleFederationPlugin.ts | 2 - .../ModuleFederationRuntimePlugin.ts | 14 ++++ packages/rspack/src/exports.ts | 9 +++ .../rspack/src/sharing/ProvideSharedPlugin.ts | 12 +++ packages/rspack/src/sharing/SharePlugin.ts | 10 +++ .../__snapshots__/StatsTestCases.test.ts.snap | 76 ------------------- 18 files changed, 152 insertions(+), 78 deletions(-) diff --git a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs b/crates/rspack_binding_options/src/options/raw_builtins/mod.rs index e88e05449e4..86bfd93fa5e 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs +++ b/crates/rspack_binding_options/src/options/raw_builtins/mod.rs @@ -44,7 +44,11 @@ use rspack_plugin_swc_js_minimizer::SwcJsMinimizerRspackPlugin; use rspack_plugin_wasm::enable_wasm_loading_plugin; use rspack_plugin_web_worker_template::web_worker_template_plugin; +<<<<<<< HEAD use self::raw_mf::{RawConsumeOptions, RawContainerReferencePluginOptions, RawProvideOptions}; +======= +use self::raw_mf::{RawContainerReferencePluginOptions, RawProvideOptions}; +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) pub use self::{ raw_banner::RawBannerPluginOptions, raw_copy::RawCopyRspackPluginOptions, raw_html::RawHtmlRspackPluginOptions, raw_limit_chunk_count::RawLimitChunkCountPluginOptions, @@ -84,7 +88,10 @@ pub enum BuiltinPluginName { ContainerReferencePlugin, ModuleFederationRuntimePlugin, ProvideSharedPlugin, +<<<<<<< HEAD ConsumeSharedPlugin, +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) // rspack specific plugins HttpExternalsRspackPlugin, @@ -226,6 +233,7 @@ impl RawOptionsApply for BuiltinPlugin { provides.sort_unstable_by_key(|(k, _)| k.to_string()); plugins.push(ProvideSharedPlugin::new(provides).boxed()) } +<<<<<<< HEAD BuiltinPluginName::ConsumeSharedPlugin => { let consumes: Vec<_> = downcast_into::>(self.options)? .into_iter() @@ -233,6 +241,8 @@ impl RawOptionsApply for BuiltinPlugin { .collect(); plugins.push(ConsumeSharedPlugin::new(consumes).boxed()) } +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) // rspack specific plugins BuiltinPluginName::HttpExternalsRspackPlugin => { diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_mf.rs b/crates/rspack_binding_options/src/options/raw_builtins/raw_mf.rs index 472bd30e9ed..4a808557d4c 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_mf.rs +++ b/crates/rspack_binding_options/src/options/raw_builtins/raw_mf.rs @@ -98,7 +98,11 @@ pub struct RawProvideOptions { pub share_key: String, pub share_scope: String, #[napi(ts_type = "string | false | undefined")] +<<<<<<< HEAD pub version: Option, +======= + pub version: Option, +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) pub eager: bool, } @@ -109,13 +113,18 @@ impl From for (String, ProvideOptions) { ProvideOptions { share_key: value.share_key, share_scope: value.share_scope, +<<<<<<< HEAD version: value.version.map(|v| RawVersionWrapper(v).into()), +======= + version: value.version.map(|v| RawProvideVersionWrapper(v).into()), +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) eager: value.eager, }, ) } } +<<<<<<< HEAD #[derive(Debug)] #[napi(object)] pub struct RawConsumeOptions { @@ -157,12 +166,21 @@ struct RawVersionWrapper(RawVersion); impl From for ProvideVersion { fn from(value: RawVersionWrapper) -> Self { +======= +pub type RawProvideVersion = Either; + +struct RawProvideVersionWrapper(RawProvideVersion); + +impl From for ProvideVersion { + fn from(value: RawProvideVersionWrapper) -> Self { +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) match value.0 { Either::A(s) => ProvideVersion::Version(s), Either::B(_) => ProvideVersion::False, } } } +<<<<<<< HEAD impl From for ConsumeVersion { fn from(value: RawVersionWrapper) -> Self { @@ -172,3 +190,5 @@ impl From for ConsumeVersion { } } } +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) diff --git a/crates/rspack_core/src/build_chunk_graph/code_splitter.rs b/crates/rspack_core/src/build_chunk_graph/code_splitter.rs index 36d735aeefe..e3c6349dc2c 100644 --- a/crates/rspack_core/src/build_chunk_graph/code_splitter.rs +++ b/crates/rspack_core/src/build_chunk_graph/code_splitter.rs @@ -175,12 +175,15 @@ impl<'me> CodeSplitter<'me> { .entry(entrypoint.ukey) .or_default() .extend(included_modules); +<<<<<<< HEAD if let Some(name) = entrypoint.name() { self .named_chunk_groups .insert(name.to_string(), entrypoint.ukey); } +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) } let mut runtime_chunks = HashSet::default(); diff --git a/crates/rspack_core/src/dependency/dependency_type.rs b/crates/rspack_core/src/dependency/dependency_type.rs index f10a4aa781d..3ee4abf2de0 100644 --- a/crates/rspack_core/src/dependency/dependency_type.rs +++ b/crates/rspack_core/src/dependency/dependency_type.rs @@ -72,8 +72,11 @@ pub enum DependencyType { ProvideSharedModule, /// provide module for shared ProvideModuleForShared, +<<<<<<< HEAD /// consume shared fallback ConsumeSharedFallback, +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) Custom(Box), // TODO it will increase large layout size } @@ -118,7 +121,10 @@ impl DependencyType { DependencyType::RemoteToExternal => Cow::Borrowed("remote to external"), DependencyType::ProvideSharedModule => Cow::Borrowed("provide shared module"), DependencyType::ProvideModuleForShared => Cow::Borrowed("provide module for shared"), +<<<<<<< HEAD DependencyType::ConsumeSharedFallback => Cow::Borrowed("consume shared fallback"), +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) } } } diff --git a/crates/rspack_core/src/dependency/runtime_template.rs b/crates/rspack_core/src/dependency/runtime_template.rs index b3372b8a147..6b792ca0326 100644 --- a/crates/rspack_core/src/dependency/runtime_template.rs +++ b/crates/rspack_core/src/dependency/runtime_template.rs @@ -1,7 +1,11 @@ use swc_core::ecma::atoms::JsWord; use crate::{ +<<<<<<< HEAD get_import_var, property_access, to_comment, AsyncDependenciesBlockIdentifier, Compilation, +======= + get_import_var, property_access, AsyncDependenciesBlockIdentifier, Compilation, +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) DependenciesBlock, DependencyId, ExportsType, FakeNamespaceObjectMode, InitFragmentExt, InitFragmentKey, InitFragmentStage, ModuleGraph, ModuleIdentifier, NormalInitFragment, RuntimeGlobals, TemplateContext, diff --git a/crates/rspack_core/src/lib.rs b/crates/rspack_core/src/lib.rs index 2291c85b444..fd984e74dc4 100644 --- a/crates/rspack_core/src/lib.rs +++ b/crates/rspack_core/src/lib.rs @@ -140,8 +140,12 @@ pub enum ModuleType { Asset, Runtime, Remote, +<<<<<<< HEAD ProvideShared, ConsumeShared, +======= + Provide, +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) } impl ModuleType { @@ -227,8 +231,12 @@ impl ModuleType { ModuleType::AssetInline => "asset/inline", ModuleType::Runtime => "runtime", ModuleType::Remote => "remote-module", +<<<<<<< HEAD ModuleType::ProvideShared => "provide-module", ModuleType::ConsumeShared => "consume-shared-module", +======= + ModuleType::Provide => "provide-module", +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) } } } diff --git a/crates/rspack_core/src/mf/sharing/mod.rs b/crates/rspack_core/src/mf/sharing/mod.rs index aaaa00dcf0a..85f80958e3f 100644 --- a/crates/rspack_core/src/mf/sharing/mod.rs +++ b/crates/rspack_core/src/mf/sharing/mod.rs @@ -1,7 +1,10 @@ +<<<<<<< HEAD pub mod consume_shared_fallback_dependency; pub mod consume_shared_module; pub mod consume_shared_plugin; pub mod consume_shared_runtime_module; +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) pub mod provide_for_shared_dependency; pub mod provide_shared_dependency; pub mod provide_shared_module; diff --git a/crates/rspack_core/src/mf/sharing/provide_shared_module.rs b/crates/rspack_core/src/mf/sharing/provide_shared_module.rs index 86a5a9f3a51..87e3b63cdd3 100644 --- a/crates/rspack_core/src/mf/sharing/provide_shared_module.rs +++ b/crates/rspack_core/src/mf/sharing/provide_shared_module.rs @@ -40,6 +40,7 @@ impl ProvideSharedModule { request: String, eager: bool, ) -> Self { +<<<<<<< HEAD let identifier = format!( "provide shared module ({}) {}@{} = {}", &share_scope, &name, &version, &request @@ -50,6 +51,20 @@ impl ProvideSharedModule { identifier: ModuleIdentifier::from(identifier.clone()), lib_ident: format!("webpack/sharing/provide/{}/{}", &share_scope, &name), readable_identifier: identifier, +======= + Self { + blocks: Vec::new(), + dependencies: Vec::new(), + identifier: ModuleIdentifier::from(format!( + "provide shared module ({}) {}@{} = {}", + &share_scope, &name, &version, &request + )), + lib_ident: format!("webpack/sharing/provide/{}/{}", &share_scope, &name), + readable_identifier: format!( + "provide shared module ({}) {}@{} = {}", + &share_scope, &name, &version, &request + ), +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) name, share_scope, version, @@ -90,7 +105,11 @@ impl Module for ProvideSharedModule { } fn module_type(&self) -> &ModuleType { +<<<<<<< HEAD &ModuleType::ProvideShared +======= + &ModuleType::Provide +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) } fn source_types(&self) -> &[SourceType] { @@ -123,7 +142,11 @@ impl Module for ProvideSharedModule { if self.eager { dependencies.push(dep as BoxDependency); } else { +<<<<<<< HEAD let mut block = AsyncDependenciesBlock::new(self.identifier, "", None); +======= + let mut block = AsyncDependenciesBlock::new(self.identifier, ""); +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) block.add_dependency(dep); blocks.push(block); } diff --git a/crates/rspack_core/src/mf/sharing/provide_shared_plugin.rs b/crates/rspack_core/src/mf/sharing/provide_shared_plugin.rs index ddad5ff4e68..bb29bb71135 100644 --- a/crates/rspack_core/src/mf/sharing/provide_shared_plugin.rs +++ b/crates/rspack_core/src/mf/sharing/provide_shared_plugin.rs @@ -3,7 +3,11 @@ use std::fmt; use async_trait::async_trait; use once_cell::sync::Lazy; use regex::Regex; +<<<<<<< HEAD use rspack_error::Result; +======= +use rspack_error::{Error, InternalError, Result, Severity}; +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) use rspack_loader_runner::ResourceData; use rustc_hash::FxHashMap; use tokio::sync::RwLock; @@ -83,7 +87,11 @@ impl ProvideSharedPlugin { #[allow(clippy::too_many_arguments)] pub async fn provide_shared_module( &self, +<<<<<<< HEAD _key: &str, +======= + key: &str, +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) share_key: &str, share_scope: &str, version: Option<&ProvideVersion>, @@ -91,8 +99,12 @@ impl ProvideSharedPlugin { resource: &str, resource_data: &ResourceData, ) -> Result<()> { +<<<<<<< HEAD // TODO: emit warning // let error_header = "No version specified and unable to automatically determine one."; +======= + let error_header = "No version specified and unable to automatically determine one."; +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) if let Some(version) = version { self.resolved_provide_map.write().await.insert( resource.to_string(), @@ -118,10 +130,17 @@ impl ProvideSharedPlugin { }, ); } else { +<<<<<<< HEAD // return Err(Error::InternalError(InternalError::new(format!("{error_header} No version in description file (usually package.json). Add version to description file {}, or manually specify version in shared config. shared module {key} -> {resource}", description.path().display()), Severity::Warn))); } } else { // return Err(Error::InternalError(InternalError::new(format!("{error_header} No description file (usually package.json) found. Add description file with name and version, or manually specify version in shared config. shared module {key} -> {resource}"), Severity::Warn))); +======= + return Err(Error::InternalError(InternalError::new(format!("{error_header} No version in description file (usually package.json). Add version to description file {}, or manually specify version in shared config. shared module {key} -> {resource}", description.path().display()), Severity::Warn))); + } + } else { + return Err(Error::InternalError(InternalError::new(format!("{error_header} No description file (usually package.json) found. Add description file with name and version, or manually specify version in shared config. shared module {key} -> {resource}"), Severity::Warn))); +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) } Ok(()) } diff --git a/crates/rspack_core/src/normal_module_factory.rs b/crates/rspack_core/src/normal_module_factory.rs index 1728419935d..982ba16b29b 100644 --- a/crates/rspack_core/src/normal_module_factory.rs +++ b/crates/rspack_core/src/normal_module_factory.rs @@ -636,7 +636,10 @@ impl NormalModuleFactory { dependency_type: data.dependency.dependency_type().clone(), resolve_data_request: dependency.request(), resource_resolve_data: resource_data.clone(), +<<<<<<< HEAD context: data.context.clone(), +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) }; let module = if let Some(module) = self .plugin_driver diff --git a/crates/rspack_core/src/plugin/args.rs b/crates/rspack_core/src/plugin/args.rs index 0c8822cc6a7..4b7fcdb99c4 100644 --- a/crates/rspack_core/src/plugin/args.rs +++ b/crates/rspack_core/src/plugin/args.rs @@ -87,7 +87,10 @@ pub struct NormalModuleCreateData<'a> { pub dependency_type: DependencyType, pub resolve_data_request: &'a str, pub resource_resolve_data: ResourceData, +<<<<<<< HEAD pub context: Context, +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) } #[derive(Debug, Clone)] diff --git a/packages/rspack/src/builtin-plugin/base.ts b/packages/rspack/src/builtin-plugin/base.ts index b23ff8182f1..6c3410428b2 100644 --- a/packages/rspack/src/builtin-plugin/base.ts +++ b/packages/rspack/src/builtin-plugin/base.ts @@ -45,8 +45,13 @@ export enum BuiltinPluginName { OldSplitChunksPlugin = "OldSplitChunksPlugin", ContainerPlugin = "ContainerPlugin", ContainerReferencePlugin = "ContainerReferencePlugin", +<<<<<<< HEAD ModuleFederationRuntimePlugin = "ModuleFederationRuntimePlugin" >>>>>>> c30ae9213 (feat: Module Federation, part 2, ContainerReferencePlugin (#4735)) +======= + ModuleFederationRuntimePlugin = "ModuleFederationRuntimePlugin", + ProvideSharedPlugin = "ProvideSharedPlugin" +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) } export abstract class RspackBuiltinPlugin implements RspackPluginInstance { diff --git a/packages/rspack/src/container/ModuleFederationPlugin.ts b/packages/rspack/src/container/ModuleFederationPlugin.ts index ba080769428..dde18df0469 100644 --- a/packages/rspack/src/container/ModuleFederationPlugin.ts +++ b/packages/rspack/src/container/ModuleFederationPlugin.ts @@ -40,8 +40,6 @@ export class ModuleFederationPlugin { ) { compiler.options.output.enabledLibraryTypes!.push(library.type); } - const mfRuntimePlugin = new ModuleFederationRuntimePlugin(); - mfRuntimePlugin.apply(compiler); compiler.hooks.afterPlugins.tap("ModuleFederationPlugin", () => { if ( options.exposes && diff --git a/packages/rspack/src/container/ModuleFederationRuntimePlugin.ts b/packages/rspack/src/container/ModuleFederationRuntimePlugin.ts index cbc50b78b63..e40a8fe9427 100644 --- a/packages/rspack/src/container/ModuleFederationRuntimePlugin.ts +++ b/packages/rspack/src/container/ModuleFederationRuntimePlugin.ts @@ -7,7 +7,11 @@ const ModuleFederationRuntimePlugin2 = create( () => undefined ); +<<<<<<< HEAD const compilerToPlugins = new WeakMap>(); +======= +const compilerToPlugins = new WeakMap(); +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) export class ModuleFederationRuntimePlugin { apply(compiler: Compiler) { @@ -19,9 +23,13 @@ export class ModuleFederationRuntimePlugin { const plugins = compilerToPlugins.get(compiler); if (plugins) { // TODO: move to rust side so don't depend on dataUrl? +<<<<<<< HEAD const entry = [...plugins] .map(p => `import ${JSON.stringify(p)};`) .join("\n"); +======= + const entry = plugins.map(p => `import "${p}";`).join("\n"); +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) new EntryPlugin(compiler.context, `data:text/javascript,${entry}`, { name: undefined }).apply(compiler); @@ -34,8 +42,14 @@ export class ModuleFederationRuntimePlugin { static addPlugin(compiler: Compiler, plugin: string) { let plugins = compilerToPlugins.get(compiler); if (!plugins) { +<<<<<<< HEAD compilerToPlugins.set(compiler, (plugins = new Set())); } plugins.add(plugin); +======= + compilerToPlugins.set(compiler, (plugins = [])); + } + plugins.push(plugin); +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) } } diff --git a/packages/rspack/src/exports.ts b/packages/rspack/src/exports.ts index a37d5eb75de..cced442b0f3 100644 --- a/packages/rspack/src/exports.ts +++ b/packages/rspack/src/exports.ts @@ -146,7 +146,10 @@ export const container = { }; import { ProvideSharedPlugin } from "./sharing/ProvideSharedPlugin"; +<<<<<<< HEAD import { ConsumeSharedPlugin } from "./sharing/ConsumeSharedPlugin"; +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) import { SharePlugin } from "./sharing/SharePlugin"; export type { ProvideSharedPluginOptions, @@ -156,6 +159,7 @@ export type { ProvidesObject } from "./sharing/ProvideSharedPlugin"; export type { +<<<<<<< HEAD ConsumeSharedPluginOptions, Consumes, ConsumesConfig, @@ -163,6 +167,8 @@ export type { ConsumesObject } from "./sharing/ConsumeSharedPlugin"; export type { +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) SharePluginOptions, Shared, SharedConfig, @@ -171,7 +177,10 @@ export type { } from "./sharing/SharePlugin"; export const sharing = { ProvideSharedPlugin, +<<<<<<< HEAD ConsumeSharedPlugin, +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) SharePlugin }; diff --git a/packages/rspack/src/sharing/ProvideSharedPlugin.ts b/packages/rspack/src/sharing/ProvideSharedPlugin.ts index 206c167dfc0..6f3aeee7d23 100644 --- a/packages/rspack/src/sharing/ProvideSharedPlugin.ts +++ b/packages/rspack/src/sharing/ProvideSharedPlugin.ts @@ -1,5 +1,13 @@ import { BuiltinPlugin, RawProvideOptions } from "@rspack/binding"; +<<<<<<< HEAD import { BuiltinPluginName, RspackBuiltinPlugin } from "../builtin-plugin/base"; +======= +import { + BuiltinPluginName, + RspackBuiltinPlugin, + create +} from "../builtin-plugin/base"; +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) import { parseOptions } from "../container/options"; import { Compiler } from "../Compiler"; import { ModuleFederationRuntimePlugin } from "../container/ModuleFederationRuntimePlugin"; @@ -51,7 +59,11 @@ export class ProvideSharedPlugin extends RspackBuiltinPlugin { raw(compiler: Compiler): BuiltinPlugin { ModuleFederationRuntimePlugin.addPlugin( compiler, +<<<<<<< HEAD require.resolve("./initializeSharing.js") +======= + require.resolve("../sharing/initializeSharing.js") +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) ); return { name: this.name as any, diff --git a/packages/rspack/src/sharing/SharePlugin.ts b/packages/rspack/src/sharing/SharePlugin.ts index 2bdb8ae0135..ebd2af52ec5 100644 --- a/packages/rspack/src/sharing/SharePlugin.ts +++ b/packages/rspack/src/sharing/SharePlugin.ts @@ -1,6 +1,9 @@ import { Compiler } from "../Compiler"; import { parseOptions } from "../container/options"; +<<<<<<< HEAD import { ConsumeSharedPlugin } from "./ConsumeSharedPlugin"; +======= +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) import { ProvideSharedPlugin } from "./ProvideSharedPlugin"; import { isRequiredVersion } from "./utils"; @@ -77,10 +80,17 @@ export class SharePlugin { } apply(compiler: Compiler) { +<<<<<<< HEAD new ConsumeSharedPlugin({ shareScope: this._shareScope, consumes: this._consumes }).apply(compiler); +======= + // new ConsumeSharedPlugin({ + // shareScope: this._shareScope, + // consumes: this._consumes + // }).apply(compiler); +>>>>>>> 24ebe5e86 (feat: Module Federation, part 3, ProvideSharedPlugin (#4778)) new ProvideSharedPlugin({ shareScope: this._shareScope, provides: this._provides diff --git a/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap b/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap index de8c85894a2..72758704262 100644 --- a/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap +++ b/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap @@ -190,11 +190,7 @@ import rawModule from './raw.png'; "errors": [], "errorsCount": 0, "filteredModules": undefined, -<<<<<<< HEAD "hash": "62ac3b1146fb1565fbd4", -======= - "hash": "d039dac81f5ffc79248d", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "logging": {}, "modules": [ { @@ -384,11 +380,7 @@ chunk {main} bundle.js (main) [entry] esm import ./stringModule [10] webpack/runtime/public_path {main} webpack/runtime/make_namespace_object {main} -<<<<<<< HEAD Rspack compiled successfully (62ac3b1146fb1565fbd4)" -======= -Rspack compiled successfully (d039dac81f5ffc79248d)" ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) `; exports[`StatsTestCases should print correct stats for filename 1`] = ` @@ -552,11 +544,7 @@ exports[`StatsTestCases should print correct stats for filename 1`] = ` "errors": [], "errorsCount": 0, "filteredModules": undefined, -<<<<<<< HEAD "hash": "d11c74c648d060ebcdfd", -======= - "hash": "73d6dbf085ec9e712627", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "logging": {}, "modules": [ { @@ -799,11 +787,7 @@ webpack/runtime/make_namespace_object {main} webpack/runtime/require_chunk_loading {main} webpack/runtime/define_property_getters {main} webpack/runtime/get_chunk_filename/__webpack_require__.u {main} -<<<<<<< HEAD Rspack compiled successfully (d11c74c648d060ebcdfd)" -======= -Rspack compiled successfully (73d6dbf085ec9e712627)" ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) `; exports[`StatsTestCases should print correct stats for hot+production 1`] = ` @@ -1532,11 +1516,7 @@ import(/* webpackChunkName: "c" */ "./c"); "errors": [], "errorsCount": 0, "filteredModules": undefined, -<<<<<<< HEAD "hash": "4da06cdbffcc858493d3", -======= - "hash": "5a43126faa8aa34180ae", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "logging": {}, "modules": [ { @@ -2152,11 +2132,7 @@ import(/* webpackChunkName: "c" */ "./c"); "errors": [], "errorsCount": 0, "filteredModules": undefined, -<<<<<<< HEAD "hash": "b7c4a03979d24b362924", -======= - "hash": "654182725b3a269e85d7", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "logging": {}, "modules": [ { @@ -2842,11 +2818,7 @@ import(/* webpackChunkName: "c" */ "./c"); "errors": [], "errorsCount": 0, "filteredModules": undefined, -<<<<<<< HEAD "hash": "64096f05f9e44ebb2bba", -======= - "hash": "c31e69fff0635b11a4a2", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "logging": {}, "modules": [ { @@ -3566,11 +3538,7 @@ import(/* webpackChunkName: "c" */ "./c"); "errors": [], "errorsCount": 0, "filteredModules": undefined, -<<<<<<< HEAD "hash": "2a2f992ca23e8aee62a6", -======= - "hash": "614a08891b55fa664bf1", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "logging": {}, "modules": [ { @@ -3941,11 +3909,7 @@ import(/* webpackChunkName: "c" */ "./c"); ], "errors": [], "errorsCount": 0, -<<<<<<< HEAD "hash": "4da06cdbffcc858493d3b7c4a03979d24b36292464096f05f9e44ebb2bba2a2f992ca23e8aee62a6", -======= - "hash": "5a43126faa8aa34180ae654182725b3a269e85d7c31e69fff0635b11a4a2614a08891b55fa664bf1", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "warnings": [], "warningsCount": 0, } @@ -3984,11 +3948,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin webpack/runtime/make_namespace_object {main} webpack/runtime/define_property_getters {main} webpack/runtime/create_fake_namespace_object {main} -<<<<<<< HEAD 1 chunks compiled successfully (4da06cdbffcc858493d3) -======= - 1 chunks compiled successfully (5a43126faa8aa34180ae) ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) 2 chunks: PublicPath: (none) @@ -4026,11 +3986,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin webpack/runtime/define_property_getters {main} webpack/runtime/create_fake_namespace_object {main} webpack/runtime/get_chunk_filename/__webpack_require__.u {main} -<<<<<<< HEAD 2 chunks compiled successfully (b7c4a03979d24b362924) -======= - 2 chunks compiled successfully (654182725b3a269e85d7) ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) 3 chunks: PublicPath: (none) @@ -4070,11 +4026,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin webpack/runtime/define_property_getters {main} webpack/runtime/create_fake_namespace_object {main} webpack/runtime/get_chunk_filename/__webpack_require__.u {main} -<<<<<<< HEAD 3 chunks compiled successfully (64096f05f9e44ebb2bba) -======= - 3 chunks compiled successfully (c31e69fff0635b11a4a2) ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) 4 chunks: PublicPath: (none) @@ -4116,11 +4068,7 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin webpack/runtime/define_property_getters {main} webpack/runtime/create_fake_namespace_object {main} webpack/runtime/get_chunk_filename/__webpack_require__.u {main} -<<<<<<< HEAD 4 chunks compiled successfully (2a2f992ca23e8aee62a6)" -======= - 4 chunks compiled successfully (614a08891b55fa664bf1)" ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) `; exports[`StatsTestCases should print correct stats for loader-builtin-swc-plugin-warn 1`] = ` @@ -5191,11 +5139,7 @@ console.log(a); ], "errorsCount": 1, "filteredModules": undefined, -<<<<<<< HEAD "hash": "26912d71518dd751cffb", -======= - "hash": "b6cb152656035d1a4dd0", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "logging": {}, "modules": [ { @@ -5396,11 +5340,7 @@ error[internal]: Resolve error -<<<<<<< HEAD Rspack compiled with 1 error (26912d71518dd751cffb)" -======= -Rspack compiled with 1 error (b6cb152656035d1a4dd0)" ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) `; exports[`StatsTestCases should print correct stats for resolve-unexpected-exports-in-pkg 1`] = ` @@ -5544,11 +5484,7 @@ console.log(a); ], "errorsCount": 1, "filteredModules": undefined, -<<<<<<< HEAD "hash": "a4659b8ec3c289e07669", -======= - "hash": "fa95ef35702693fe1d8e", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "logging": {}, "modules": [ { @@ -5743,11 +5679,7 @@ error[internal]: Export should be relative path and start with "./", but got ../ -<<<<<<< HEAD Rspack compiled with 1 error (a4659b8ec3c289e07669)" -======= -Rspack compiled with 1 error (fa95ef35702693fe1d8e)" ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) `; exports[`StatsTestCases should print correct stats for runtime-modules 1`] = ` @@ -6187,11 +6119,7 @@ import rawModule from './raw.png'; "errors": [], "errorsCount": 0, "filteredModules": undefined, -<<<<<<< HEAD "hash": "7a6e65b1aedebf8e24aa", -======= - "hash": "e5e69c13c4066c103b61", ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) "logging": {}, "modules": [ { @@ -6397,11 +6325,7 @@ runtime modules 4 modules ./raw.png ./index.js ./stringModule.js -<<<<<<< HEAD Rspack compiled successfully (7a6e65b1aedebf8e24aa)" -======= -Rspack compiled successfully (e5e69c13c4066c103b61)" ->>>>>>> ce3a66a5c (feat: bump swc to support `format.inline_script` (#4786)) `; exports[`StatsTestCases should print correct stats for stats-hooks 1`] = `