-
-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
851 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
crates/rspack_binding_options/src/options/raw_builtins/raw_mf.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use napi_derive::napi; | ||
use rspack_core::mf::{ContainerPluginOptions, ExposeOptions}; | ||
|
||
use crate::RawLibraryOptions; | ||
|
||
#[derive(Debug)] | ||
#[napi(object)] | ||
pub struct RawContainerPluginOptions { | ||
pub name: String, | ||
pub share_scope: String, | ||
pub library: RawLibraryOptions, | ||
pub runtime: Option<String>, | ||
pub filename: Option<String>, | ||
pub exposes: Vec<RawExposeOptions>, | ||
} | ||
|
||
impl From<RawContainerPluginOptions> for ContainerPluginOptions { | ||
fn from(value: RawContainerPluginOptions) -> Self { | ||
Self { | ||
name: value.name, | ||
share_scope: value.share_scope, | ||
library: value.library.into(), | ||
runtime: value.runtime, | ||
filename: value.filename.map(|f| f.into()), | ||
exposes: value.exposes.into_iter().map(|e| e.into()).collect(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
#[napi(object)] | ||
pub struct RawExposeOptions { | ||
pub key: String, | ||
pub name: Option<String>, | ||
pub import: Vec<String>, | ||
} | ||
|
||
impl From<RawExposeOptions> for (String, ExposeOptions) { | ||
fn from(value: RawExposeOptions) -> Self { | ||
( | ||
value.key, | ||
ExposeOptions { | ||
name: value.name, | ||
import: value.import, | ||
}, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
crates/rspack_core/src/mf/container/container_entry_dependency.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use super::ExposeOptions; | ||
use crate::{ | ||
AsContextDependency, AsDependencyTemplate, Dependency, DependencyCategory, DependencyId, | ||
DependencyType, ModuleDependency, | ||
}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ContainerEntryDependency { | ||
id: DependencyId, | ||
pub name: String, | ||
pub exposes: Vec<(String, ExposeOptions)>, | ||
pub share_scope: String, | ||
resource_identifier: String, | ||
} | ||
|
||
impl ContainerEntryDependency { | ||
pub fn new(name: String, exposes: Vec<(String, ExposeOptions)>, share_scope: String) -> Self { | ||
let resource_identifier = format!("container-entry-{}", &name); | ||
Self { | ||
id: DependencyId::new(), | ||
name, | ||
exposes, | ||
share_scope, | ||
resource_identifier, | ||
} | ||
} | ||
} | ||
|
||
impl Dependency for ContainerEntryDependency { | ||
fn dependency_debug_name(&self) -> &'static str { | ||
"ContainerEntryDependency" | ||
} | ||
|
||
fn id(&self) -> &DependencyId { | ||
&self.id | ||
} | ||
|
||
fn category(&self) -> &DependencyCategory { | ||
&DependencyCategory::Esm | ||
} | ||
|
||
fn dependency_type(&self) -> &DependencyType { | ||
&DependencyType::ContainerEntry | ||
} | ||
|
||
fn resource_identifier(&self) -> Option<&str> { | ||
Some(&self.resource_identifier) | ||
} | ||
} | ||
|
||
impl ModuleDependency for ContainerEntryDependency { | ||
fn request(&self) -> &str { | ||
&self.resource_identifier | ||
} | ||
|
||
fn user_request(&self) -> &str { | ||
&self.resource_identifier | ||
} | ||
|
||
fn set_request(&mut self, _request: String) {} | ||
} | ||
|
||
impl AsContextDependency for ContainerEntryDependency {} | ||
impl AsDependencyTemplate for ContainerEntryDependency {} |
Oops, something went wrong.