Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
3c0a94e
feat: treeshake share
2heal1 Oct 24, 2025
e27a87e
fix(module-federation): correct shared module name and optimize tree …
2heal1 Dec 9, 2025
f7e6adf
feat(module-federation): add treeshakeSharedExcludedPlugins option
2heal1 Dec 11, 2025
4c2435c
chore: add watchRun
2heal1 Dec 12, 2025
617f522
fix(shared-modules): handle undefined moduleToHandlerMapping and prev…
2heal1 Dec 15, 2025
c976e7b
test(container-1-5): add ui-lib package for treeshake shared infer st…
2heal1 Dec 15, 2025
8a6a7d9
chore: merge main
2heal1 Dec 22, 2025
c38ded8
fix(shared_used_exports): handle scoped package names in shared exports
2heal1 Dec 22, 2025
22d591c
chore: update critical file
2heal1 Dec 22, 2025
c8f933e
feat(module-federation): add target and plugins to build info for tre…
2heal1 Dec 24, 2025
ae6c179
docs: update field
2heal1 Dec 30, 2025
226445c
feat: add treeshakeSharedPlugins
2heal1 Dec 30, 2025
a5ad101
chore: merge main
2heal1 Dec 30, 2025
13a91d6
Merge branch 'main' into feat/shared-treeshake
2heal1 Dec 30, 2025
32c765e
fix: lint
2heal1 Dec 30, 2025
ef4bc66
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 4, 2026
df14862
fix: lockfile
2heal1 Jan 4, 2026
cf4486a
fix: lint
2heal1 Jan 4, 2026
dcc9262
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 5, 2026
0043280
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 5, 2026
0e2d2c3
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 6, 2026
4659d99
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 6, 2026
2f52780
chore: rename config
2heal1 Jan 6, 2026
aa18a19
chore(deps): update patch npm dependencies (#12647)
renovate[bot] Jan 7, 2026
ece0fee
chore(deps): update patch crates (#12646)
renovate[bot] Jan 7, 2026
edce5bd
chore: run ci/eco-ci/eco-benchmark on v2 branch (#12650)
LingyuCoder Jan 7, 2026
44a7564
fix: report error when access module_graph in loader (#12639)
hardfist Jan 7, 2026
25a4021
feat(rstest): add preserveNewUrl option to keep new URL untouched (#1…
fi3ework Jan 7, 2026
d424733
fix(lint): enable @typescript-eslint/await-thenable rule (#12644)
tt-a1i Jan 7, 2026
86634a0
refactor: afterCodeGeneration hook use read only compilation ref (#12…
stormslowly Jan 7, 2026
f4c7791
fix(lint): enable @typescript-eslint/require-await rule (#12664)
tt-a1i Jan 7, 2026
9400b65
chore(deps): update github-actions (#12645)
renovate[bot] Jan 8, 2026
4ecc5cb
fix(lint): enable @typescript-eslint/return-await rule (#12665)
tt-a1i Jan 8, 2026
2221d14
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 8, 2026
ed4b6ed
refactor: make compilation readonly for runtimeModule hook (#12670)
hardfist Jan 8, 2026
3b1926f
feat: add constructor name for JS runtime modules (#12673)
LingyuCoder Jan 8, 2026
2feb455
fix: incremental rebuild no code generation entry panic (#12643)
jerrykingxyz Jan 8, 2026
70ffab9
refactor: unify artifact clear logic (#12677)
hardfist Jan 8, 2026
29642b2
refactor: use DerfOpt's take/replace assist artifact mutation (#12659)
stormslowly Jan 8, 2026
219a773
feat: rspack_cacheable context expose project root (#12685)
jerrykingxyz Jan 9, 2026
0d1d58f
feat: rspack_cacheable add portable path & portable string (#12688)
jerrykingxyz Jan 9, 2026
b81dfa2
fix: inlined export invalid syntax comment (#12681)
ahabhgk Jan 9, 2026
6ee0d4b
feat: add `requireAlias` option to control require variable renaming …
LingyuCoder Jan 9, 2026
a4152c5
fix(test): flaky test due to calling toJSON while hot updating (#12694)
stormslowly Jan 12, 2026
df72860
feat: impl `sync_trace` for `logger` tracing layer (#12687)
CPunisher Jan 12, 2026
eb5635c
feat: add warning when requireAlias is disabled (#12700)
LingyuCoder Jan 12, 2026
b8e674b
refactor: rename tree shaking field name
2heal1 Jan 12, 2026
b21d2ec
revert: "feat: add warning when requireAlias is disabled" (#12702)
LingyuCoder Jan 12, 2026
ec24006
feat: use rspack-vue-loader to support Vue hot update (#12698)
9aoy Jan 12, 2026
d67ed4a
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 12, 2026
2fb1f1c
chore: update artificat
2heal1 Jan 12, 2026
31ce58a
chore: replace async processAssets hooks with sync versions
2heal1 Jan 12, 2026
d02192f
fix: `environments.importMetaDirnameAndFilename` not work (#12708)
chenjiahan Jan 13, 2026
6256796
fix: dynamic entry panic when disable build cache (#12696)
SyMind Jan 13, 2026
a6892fe
fix(context-replacement): only apply changes when regex matches (#12657)
agneym Jan 13, 2026
10daee7
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 13, 2026
cad7e7a
docs: add missed doc
2heal1 Jan 13, 2026
823686a
fix: remove ueless dep
2heal1 Jan 13, 2026
3d67873
chore: update lock file
2heal1 Jan 13, 2026
a47337b
fix(mf): handle missing chunk gracefully and improve expose chunk nam…
2heal1 Jan 13, 2026
368f367
fix(type): runtimeModule.source (#12713)
9aoy Jan 13, 2026
26c87d7
chore: release 1.7.2 (#12710)
JSerFeng Jan 13, 2026
0f1b1e4
chore(deps): update dependency @rspack/plugin-react-refresh to ^1.6.0…
renovate[bot] Jan 14, 2026
a10781f
chore(deps): update dependency @shikijs/transformers to ^3.21.0 (#12719)
renovate[bot] Jan 14, 2026
0ddce9d
chore(deps): update patch crates (#12716)
renovate[bot] Jan 14, 2026
16d8c63
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 14, 2026
36866ea
test: skip recover-from-error/delete-file in watchCases (#12726)
jerrykingxyz Jan 14, 2026
25020fd
feat: support portable cache and disable by default (#12680)
jerrykingxyz Jan 14, 2026
07d3664
fix: rename reShake to secondaryTreeShaking
2heal1 Jan 14, 2026
2760cc3
Merge branch 'main' into feat/shared-treeshake
2heal1 Jan 14, 2026
58d41d1
chore: update artificat
2heal1 Jan 14, 2026
63a410a
test: use Rstest projects to define tests (#12729)
9aoy Jan 14, 2026
785c0f6
chore(deps): update patch npm dependencies (#12717)
renovate[bot] Jan 14, 2026
d9915de
refactor: move pass into separate folder and driven by run_passes (#1…
hardfist Jan 15, 2026
ad662bc
refactor(lazy-compilation): use POST request to transfer ids of acti…
stormslowly Jan 15, 2026
0eb2ee3
refactor: move logger into pass and reorg some passes (#12742)
hardfist Jan 15, 2026
cd15818
chore(lint): bump @rslint/core to 0.2.0 and enable default-param-last…
fansenze Jan 15, 2026
1138ed1
chore: merge main
2heal1 Jan 15, 2026
476c9a0
test: support filter test by absolute path (#12749)
9aoy Jan 15, 2026
ef467b4
refactor: use newtype for alias artifact (#12754)
hardfist Jan 15, 2026
cc18589
chore: bump `swc_core` from 54 to 55 (#12758)
CPunisher Jan 16, 2026
8c8a402
refactor: move all artifacts together (#12755)
hardfist Jan 16, 2026
fe1e14c
chore: limit threads for codspeed benchmark (#12763)
CPunisher Jan 16, 2026
cfa49be
chore(deps): update dependency cspell to ^9.6.0 (#12768)
renovate[bot] Jan 18, 2026
8f85030
chore(deps): update dependency emnapi to ^1.8.1 (#12769)
renovate[bot] Jan 18, 2026
2f0bc17
chore(deps): update dependency memfs to v4.53.0 (#12770)
renovate[bot] Jan 18, 2026
1dc4b72
refactor: use compilation readonly ref in codegen optimization hook (…
stormslowly Jan 19, 2026
5b35090
fix(browser): update worker format and add e2e test (#12747)
CPunisher Jan 19, 2026
ce29185
fix: update shared global name
2heal1 Jan 19, 2026
467a44d
chore: merge main
2heal1 Jan 19, 2026
3282b3d
perf: reuse container plugin
2heal1 Jan 21, 2026
c6cabed
chore: merge main
2heal1 Jan 27, 2026
2a85e0a
chore: fix merge conflict
2heal1 Jan 27, 2026
0101b8a
chore: merge main
2heal1 Feb 2, 2026
1a9ec0d
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 3, 2026
fbf727b
chore: use official version and update docs
2heal1 Feb 3, 2026
9fbc69c
chore: fix cargo clippy
2heal1 Feb 3, 2026
d7c6a31
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 3, 2026
f71ce01
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 3, 2026
7ef330a
chore: bump
2heal1 Feb 3, 2026
132f049
chore: merge main
2heal1 Feb 4, 2026
a0e1c67
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 4, 2026
5ac3ca1
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 4, 2026
44fe169
workflow: revert ci
2heal1 Feb 4, 2026
eee0673
ci: add CodSpeed performance analysis action
2heal1 Feb 4, 2026
247bd99
chore: revert cacahe implementation
2heal1 Feb 4, 2026
2db5635
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 4, 2026
9de1210
chore: merge main
2heal1 Feb 4, 2026
d62d2a5
chore: use get_referenced_exports
2heal1 Feb 4, 2026
5742f68
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 4, 2026
0aa547b
chore: revert esm depnedency change
2heal1 Feb 4, 2026
f59d807
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 4, 2026
26185ce
chore: revert esm_import_specifier_dependency change
2heal1 Feb 4, 2026
615e164
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 4, 2026
e541b7a
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 5, 2026
b4e2ed3
Merge branch 'main' into feat/shared-treeshake
2heal1 Feb 5, 2026
b33c235
refactor(mf): simplify runtime module implementations
2heal1 Feb 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions crates/node_binding/napi-binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,13 @@ export declare enum BuiltinPluginName {
SplitChunksPlugin = 'SplitChunksPlugin',
RemoveDuplicateModulesPlugin = 'RemoveDuplicateModulesPlugin',
ShareRuntimePlugin = 'ShareRuntimePlugin',
SharedUsedExportsOptimizerPlugin = 'SharedUsedExportsOptimizerPlugin',
ContainerPlugin = 'ContainerPlugin',
ContainerReferencePlugin = 'ContainerReferencePlugin',
ProvideSharedPlugin = 'ProvideSharedPlugin',
ConsumeSharedPlugin = 'ConsumeSharedPlugin',
CollectSharedEntryPlugin = 'CollectSharedEntryPlugin',
SharedContainerPlugin = 'SharedContainerPlugin',
ModuleFederationRuntimePlugin = 'ModuleFederationRuntimePlugin',
ModuleFederationManifestPlugin = 'ModuleFederationManifestPlugin',
NamedModuleIdsPlugin = 'NamedModuleIdsPlugin',
Expand Down Expand Up @@ -1876,6 +1879,11 @@ export interface RawCircularDependencyRspackPluginOptions {
onEnd?: () => void
}

export interface RawCollectShareEntryPluginOptions {
consumes: Array<RawConsumeOptions>
filename?: string
}

export interface RawCompilerPlatform {
web?: boolean | null
browser?: boolean | null
Expand All @@ -1896,6 +1904,7 @@ export interface RawConsumeOptions {
strictVersion: boolean
singleton: boolean
eager: boolean
treeShakingMode?: string
}

export interface RawConsumeSharedPluginOptions {
Expand Down Expand Up @@ -2613,6 +2622,12 @@ export interface RawOptimizationOptions {
avoidEntryIife: boolean
}

export interface RawOptimizeSharedConfig {
shareKey: string
treeShaking: boolean
usedExports?: Array<string>
}

export interface RawOptions {
name?: string
mode?: undefined | 'production' | 'development' | 'none'
Expand Down Expand Up @@ -2712,6 +2727,7 @@ export interface RawProvideOptions {
singleton?: boolean
requiredVersion?: string | false | undefined
strictVersion?: boolean
treeShakingMode?: string
}

export interface RawRelated {
Expand Down Expand Up @@ -2846,6 +2862,21 @@ export interface RawRuntimeChunkOptions {
name: string | ((entrypoint: { name: string }) => string)
}

export interface RawSharedContainerPluginOptions {
name: string
request: string
version: string
fileName?: string
library: JsLibraryOptions
}

export interface RawSharedUsedExportsOptimizerPluginOptions {
shared: Array<RawOptimizeSharedConfig>
injectTreeShakingUsedExports?: boolean
manifestFileName?: string
statsFileName?: string
}

export interface RawSizeLimitsPluginOptions {
assetFilter?: (assetFilename: string) => boolean
hints?: "error" | "warning"
Expand Down Expand Up @@ -2889,6 +2920,8 @@ export interface RawSplitChunksOptions {
export interface RawStatsBuildInfo {
buildVersion: string
buildName?: string
target?: Array<string>
plugins?: Array<string>
}

export interface RawStatsOptions {
Expand Down
3 changes: 2 additions & 1 deletion crates/rspack_binding_api/src/plugins/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ use crate::{
JsContextModuleFactoryAfterResolveDataWrapper, JsContextModuleFactoryAfterResolveResult,
JsContextModuleFactoryBeforeResolveDataWrapper, JsContextModuleFactoryBeforeResolveResult,
},
dependency::DependencyWrapper,
html::{
JsAfterEmitData, JsAfterTemplateExecutionData, JsAlterAssetTagGroupsData, JsAlterAssetTagsData,
JsBeforeAssetTagGenerationData, JsBeforeEmitData,
Expand All @@ -97,7 +98,7 @@ use crate::{
runtime::{
JsAdditionalTreeRuntimeRequirementsArg, JsAdditionalTreeRuntimeRequirementsResult,
JsCreateLinkData, JsCreateScriptData, JsLinkPrefetchData, JsLinkPreloadData, JsRuntimeGlobals,
JsRuntimeRequirementInTreeArg, JsRuntimeRequirementInTreeResult,
JsRuntimeRequirementInTreeArg, JsRuntimeRequirementInTreeResult, JsRuntimeSpec,
},
source::JsSourceToJs,
};
Expand Down
34 changes: 30 additions & 4 deletions crates/rspack_binding_api/src/raw_options/raw_builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ use napi_derive::napi;
use raw_dll::{RawDllReferenceAgencyPluginOptions, RawFlagAllModulesAsUsedPluginOptions};
use raw_ids::RawOccurrenceChunkIdsPluginOptions;
use raw_lightning_css_minimizer::RawLightningCssMinimizerRspackPluginOptions;
use raw_mf::{RawModuleFederationManifestPluginOptions, RawModuleFederationRuntimePluginOptions};
use raw_mf::{
RawCollectShareEntryPluginOptions, RawModuleFederationManifestPluginOptions,
RawModuleFederationRuntimePluginOptions, RawProvideOptions,
RawSharedUsedExportsOptimizerPluginOptions,
};
use raw_sri::RawSubresourceIntegrityPluginOptions;
use rspack_core::{BoxPlugin, Plugin, PluginExt};
use rspack_error::{Result, ToStringResultToRspackResultExt};
Expand Down Expand Up @@ -76,8 +80,9 @@ use rspack_plugin_lightning_css_minimizer::LightningCssMinimizerRspackPlugin;
use rspack_plugin_limit_chunk_count::LimitChunkCountPlugin;
use rspack_plugin_merge_duplicate_chunks::MergeDuplicateChunksPlugin;
use rspack_plugin_mf::{
ConsumeSharedPlugin, ContainerPlugin, ContainerReferencePlugin, ModuleFederationManifestPlugin,
ModuleFederationRuntimePlugin, ProvideSharedPlugin, ShareRuntimePlugin,
CollectSharedEntryPlugin, ConsumeSharedPlugin, ContainerPlugin, ContainerReferencePlugin,
ModuleFederationManifestPlugin, ModuleFederationRuntimePlugin, ProvideSharedPlugin,
ShareRuntimePlugin, SharedContainerPlugin, SharedUsedExportsOptimizerPlugin,
};
use rspack_plugin_module_info_header::ModuleInfoHeaderPlugin;
use rspack_plugin_module_replacement::{ContextReplacementPlugin, NormalModuleReplacementPlugin};
Expand Down Expand Up @@ -118,7 +123,7 @@ use self::{
raw_limit_chunk_count::RawLimitChunkCountPluginOptions,
raw_mf::{
RawConsumeSharedPluginOptions, RawContainerPluginOptions, RawContainerReferencePluginOptions,
RawProvideOptions,
RawSharedContainerPluginOptions,
},
raw_normal_replacement::RawNormalModuleReplacementPluginOptions,
raw_runtime_chunk::RawRuntimeChunkOptions,
Expand Down Expand Up @@ -171,10 +176,13 @@ pub enum BuiltinPluginName {
SplitChunksPlugin,
RemoveDuplicateModulesPlugin,
ShareRuntimePlugin,
SharedUsedExportsOptimizerPlugin,
ContainerPlugin,
ContainerReferencePlugin,
ProvideSharedPlugin,
ConsumeSharedPlugin,
CollectSharedEntryPlugin,
SharedContainerPlugin,
ModuleFederationRuntimePlugin,
ModuleFederationManifestPlugin,
NamedModuleIdsPlugin,
Expand Down Expand Up @@ -471,6 +479,12 @@ impl<'a> BuiltinPlugin<'a> {
)
.boxed(),
),
BuiltinPluginName::SharedUsedExportsOptimizerPlugin => {
let options = downcast_into::<RawSharedUsedExportsOptimizerPluginOptions>(self.options)
.map_err(|report| napi::Error::from_reason(report.to_string()))?
.into();
plugins.push(SharedUsedExportsOptimizerPlugin::new(options).boxed());
}
BuiltinPluginName::ContainerPlugin => {
plugins.push(
ContainerPlugin::new(
Expand Down Expand Up @@ -500,6 +514,18 @@ impl<'a> BuiltinPlugin<'a> {
provides.sort_unstable_by_key(|(k, _)| k.to_string());
plugins.push(ProvideSharedPlugin::new(provides).boxed())
}
BuiltinPluginName::CollectSharedEntryPlugin => {
let options = downcast_into::<RawCollectShareEntryPluginOptions>(self.options)
.map_err(|report| napi::Error::from_reason(report.to_string()))?
.into();
plugins.push(CollectSharedEntryPlugin::new(options).boxed())
}
BuiltinPluginName::SharedContainerPlugin => {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is SharedContainerPlugin, can this merge into ContainerPlugin with an additional option?

Copy link
Member Author

Choose a reason for hiding this comment

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

While both plugins share the underlying ContainerEntryDependency , I don't think they should be merged or reused at the plugin level due to their distinct responsibilities and configurations:

  1. Different Responsibilities : ContainerPlugin is a general-purpose plugin for exposing multiple modules ( exposes ), whereas SharedContainerPlugin is specialized for wrapping a single shared dependency (like react ) into an isolated container, typically used with IndependentSharedPlugin .
  2. Configuration Structure : ContainerPlugin handles a complex list of exposes map and enhanced mode settings. SharedContainerPlugin focuses on a single request and version without the concept of exposes . Reusing ContainerPlugin here would require awkward parameter conversion (e.g., faking request as an exposes entry), which increases complexity.
  3. Runtime Behavior : They inject different RuntimeModule s ( ExposeRuntimeModule vs ShareContainerRuntimeModule ). Merging them would introduce unnecessary branching logic.
    I believe reusing them at the Dependency level (as they currently do) is the correct level of abstraction.

let options = downcast_into::<RawSharedContainerPluginOptions>(self.options)
.map_err(|report| napi::Error::from_reason(report.to_string()))?
.into();
plugins.push(SharedContainerPlugin::new(options).boxed())
}
BuiltinPluginName::ConsumeSharedPlugin => plugins.push(
ConsumeSharedPlugin::new(
downcast_into::<RawConsumeSharedPluginOptions>(self.options)
Expand Down
111 changes: 106 additions & 5 deletions crates/rspack_binding_api/src/raw_options/raw_builtins/raw_mf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ use std::{collections::HashMap, sync::Arc};
use napi::Either;
use napi_derive::napi;
use rspack_plugin_mf::{
ConsumeOptions, ConsumeSharedPluginOptions, ConsumeVersion, ContainerPluginOptions,
ContainerReferencePluginOptions, ExposeOptions, ManifestExposeOption, ManifestSharedOption,
ModuleFederationManifestPluginOptions, ModuleFederationRuntimeExperimentsOptions,
ModuleFederationRuntimePluginOptions, ProvideOptions, ProvideVersion, RemoteAliasTarget,
RemoteOptions, StatsBuildInfo,
CollectSharedEntryPluginOptions, ConsumeOptions, ConsumeSharedPluginOptions, ConsumeVersion,
ContainerPluginOptions, ContainerReferencePluginOptions, ExposeOptions, ManifestExposeOption,
ManifestSharedOption, ModuleFederationManifestPluginOptions,
ModuleFederationRuntimeExperimentsOptions, ModuleFederationRuntimePluginOptions,
OptimizeSharedConfig, ProvideOptions, ProvideVersion, RemoteAliasTarget, RemoteOptions,
SharedContainerPluginOptions, SharedUsedExportsOptimizerPluginOptions, StatsBuildInfo,
};

use crate::options::{
Expand Down Expand Up @@ -115,6 +116,7 @@ pub struct RawProvideOptions {
#[napi(ts_type = "string | false | undefined")]
pub required_version: Option<RawVersion>,
pub strict_version: Option<bool>,
pub tree_shaking_mode: Option<String>,
}

impl From<RawProvideOptions> for (String, ProvideOptions) {
Expand All @@ -129,11 +131,57 @@ impl From<RawProvideOptions> for (String, ProvideOptions) {
singleton: value.singleton,
required_version: value.required_version.map(|v| RawVersionWrapper(v).into()),
strict_version: value.strict_version,
tree_shaking_mode: value.tree_shaking_mode,
},
)
}
}

#[derive(Debug)]
#[napi(object)]
pub struct RawCollectShareEntryPluginOptions {
pub consumes: Vec<RawConsumeOptions>,
pub filename: Option<String>,
}

impl From<RawCollectShareEntryPluginOptions> for CollectSharedEntryPluginOptions {
fn from(value: RawCollectShareEntryPluginOptions) -> Self {
Self {
consumes: value
.consumes
.into_iter()
.map(|provide| {
let (key, consume_options): (String, ConsumeOptions) = provide.into();
(key, std::sync::Arc::new(consume_options))
})
.collect(),
filename: value.filename,
}
}
}

#[derive(Debug)]
#[napi(object)]
pub struct RawSharedContainerPluginOptions {
pub name: String,
pub request: String,
pub version: String,
pub file_name: Option<String>,
pub library: JsLibraryOptions,
}

impl From<RawSharedContainerPluginOptions> for SharedContainerPluginOptions {
fn from(value: RawSharedContainerPluginOptions) -> Self {
SharedContainerPluginOptions {
name: value.name,
request: value.request,
version: value.version,
library: value.library.into(),
file_name: value.file_name.clone().map(Into::into),
}
}
}

#[derive(Debug)]
#[napi(object)]
pub struct RawConsumeSharedPluginOptions {
Expand All @@ -155,6 +203,52 @@ impl From<RawConsumeSharedPluginOptions> for ConsumeSharedPluginOptions {
}
}

#[derive(Debug)]
#[napi(object)]
pub struct RawOptimizeSharedConfig {
pub share_key: String,
pub tree_shaking: bool,
pub used_exports: Option<Vec<String>>,
}

impl From<RawOptimizeSharedConfig> for OptimizeSharedConfig {
fn from(value: RawOptimizeSharedConfig) -> Self {
Self {
share_key: value.share_key,
tree_shaking: value.tree_shaking,
used_exports: value.used_exports.unwrap_or_default(),
}
}
}

#[derive(Debug)]
#[napi(object)]
pub struct RawSharedUsedExportsOptimizerPluginOptions {
pub shared: Vec<RawOptimizeSharedConfig>,
pub inject_tree_shaking_used_exports: Option<bool>,
pub manifest_file_name: Option<String>,
pub stats_file_name: Option<String>,
}

impl From<RawSharedUsedExportsOptimizerPluginOptions> for SharedUsedExportsOptimizerPluginOptions {
fn from(value: RawSharedUsedExportsOptimizerPluginOptions) -> Self {
Self {
shared: value
.shared
.into_iter()
.map(|config| config.into())
.collect(),
inject_tree_shaking_used_exports: value.inject_tree_shaking_used_exports.unwrap_or(true),
manifest_file_name: value
.manifest_file_name
.and_then(|s| if s.trim().is_empty() { None } else { Some(s) }),
stats_file_name: value
.stats_file_name
.and_then(|s| if s.trim().is_empty() { None } else { Some(s) }),
}
}
}

#[derive(Debug)]
#[napi(object)]
pub struct RawConsumeOptions {
Expand All @@ -169,6 +263,7 @@ pub struct RawConsumeOptions {
pub strict_version: bool,
pub singleton: bool,
pub eager: bool,
pub tree_shaking_mode: Option<String>,
}

impl From<RawConsumeOptions> for (String, ConsumeOptions) {
Expand All @@ -185,6 +280,7 @@ impl From<RawConsumeOptions> for (String, ConsumeOptions) {
strict_version: value.strict_version,
singleton: value.singleton,
eager: value.eager,
tree_shaking_mode: value.tree_shaking_mode,
},
)
}
Expand Down Expand Up @@ -274,6 +370,9 @@ pub struct RawManifestSharedOption {
pub struct RawStatsBuildInfo {
pub build_version: String,
pub build_name: Option<String>,
// only appear when enable tree_shaking
pub target: Option<Vec<String>>,
pub plugins: Option<Vec<String>>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -337,6 +436,8 @@ impl From<RawModuleFederationManifestPluginOptions> for ModuleFederationManifest
build_info: value.build_info.map(|info| StatsBuildInfo {
build_version: info.build_version,
build_name: info.build_name,
target: info.target,
plugins: info.plugins,
}),
}
}
Expand Down
14 changes: 11 additions & 3 deletions crates/rspack_core/src/compilation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ use crate::{
ChunkRenderCacheArtifact, ChunkRenderResult, ChunkUkey, CodeGenerateCacheArtifact,
CodeGenerationJob, CodeGenerationResult, CodeGenerationResults, CompilationLogger,
CompilationLogging, CompilerOptions, CompilerPlatform, ConcatenationScope,
DependenciesDiagnosticsArtifact, DependencyCodeGeneration, DependencyTemplate,
DependenciesDiagnosticsArtifact, DependencyCodeGeneration, DependencyId, DependencyTemplate,
DependencyTemplateType, DependencyType, DerefOption, Entry, EntryData, EntryOptions,
EntryRuntime, Entrypoint, ExecuteModuleId, Filename, ImportPhase, ImportVarMap,
ImportedByDeferModulesArtifact, MemoryGCStorage, ModuleFactory, ModuleGraph,
EntryRuntime, Entrypoint, ExecuteModuleId, ExtendedReferencedExport, Filename, ImportPhase,
ImportVarMap, ImportedByDeferModulesArtifact, MemoryGCStorage, ModuleFactory, ModuleGraph,
ModuleGraphCacheArtifact, ModuleIdentifier, ModuleIdsArtifact, ModuleStaticCache, PathData,
ProcessRuntimeRequirementsCacheArtifact, ResolverFactory, RuntimeGlobals, RuntimeKeyMap,
RuntimeMode, RuntimeModule, RuntimeSpec, RuntimeSpecMap, RuntimeTemplate, SharedPluginDriver,
Expand All @@ -97,6 +97,13 @@ define_hook!(CompilationExecuteModule:
Series(module: &ModuleIdentifier, runtime_modules: &IdentifierSet, code_generation_results: &BindingCell<CodeGenerationResults>, execute_module_id: &ExecuteModuleId));
define_hook!(CompilationFinishModules: Series(compilation: &mut Compilation, async_modules_artifact: &mut AsyncModulesArtifact));
define_hook!(CompilationSeal: Series(compilation: &mut Compilation));
define_hook!(CompilationDependencyReferencedExports: Series(
compilation: &Compilation,
dependency: &DependencyId,
referenced_exports: &Option<Vec<ExtendedReferencedExport>>,
runtime: Option<&RuntimeSpec>,
module_graph: Option<&ModuleGraph>
));
define_hook!(CompilationConcatenationScope: SeriesBail(compilation: &Compilation, curr_module: ModuleIdentifier) -> ConcatenationScope);
define_hook!(CompilationOptimizeDependencies: SeriesBail(compilation: &Compilation, side_effects_optimize_artifact: &mut SideEffectsOptimizeArtifact, build_module_graph_artifact: &mut BuildModuleGraphArtifact,
diagnostics: &mut Vec<Diagnostic>) -> bool);
Expand Down Expand Up @@ -136,6 +143,7 @@ pub struct CompilationHooks {
pub succeed_module: CompilationSucceedModuleHook,
pub execute_module: CompilationExecuteModuleHook,
pub finish_modules: CompilationFinishModulesHook,
pub dependency_referenced_exports: CompilationDependencyReferencedExportsHook,
pub seal: CompilationSealHook,
pub optimize_dependencies: CompilationOptimizeDependenciesHook,
pub optimize_modules: CompilationOptimizeModulesHook,
Expand Down
Loading
Loading