-
-
Notifications
You must be signed in to change notification settings - Fork 618
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
102 changed files
with
1,069 additions
and
332 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
51 changes: 51 additions & 0 deletions
51
crates/rspack_binding_options/src/options/raw_builtins/raw_runtime_chunk.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,51 @@ | ||
use napi::Either; | ||
use napi_derive::napi; | ||
use rspack_napi::threadsafe_function::ThreadsafeFunction; | ||
use rspack_plugin_runtime_chunk::{RuntimeChunkName, RuntimeChunkOptions}; | ||
|
||
#[napi(object, object_to_js = false)] | ||
pub struct RawRuntimeChunkOptions { | ||
#[napi(ts_type = "string | ((entrypoint: { name: string }) => string)")] | ||
pub name: RawRuntimeChunkName, | ||
} | ||
|
||
impl From<RawRuntimeChunkOptions> for RuntimeChunkOptions { | ||
fn from(value: RawRuntimeChunkOptions) -> Self { | ||
Self { | ||
name: RawRuntimeChunkNameWrapper(value.name).into(), | ||
} | ||
} | ||
} | ||
|
||
type RawRuntimeChunkName = Either<String, ThreadsafeFunction<RawRuntimeChunkNameFnCtx, String>>; | ||
struct RawRuntimeChunkNameWrapper(RawRuntimeChunkName); | ||
|
||
#[napi(object)] | ||
pub struct RawRuntimeChunkNameFnCtx { | ||
pub name: String, | ||
} | ||
|
||
impl From<RawRuntimeChunkNameWrapper> for RuntimeChunkName { | ||
fn from(value: RawRuntimeChunkNameWrapper) -> Self { | ||
match value.0 { | ||
Either::A(s) => { | ||
if s == "single" { | ||
Self::Single | ||
} else if s == "multiple" { | ||
Self::Multiple | ||
} else { | ||
Self::String(s) | ||
} | ||
} | ||
Either::B(f) => RuntimeChunkName::Fn(Box::new(move |name| { | ||
let f = f.clone(); | ||
Box::pin(async move { | ||
f.call(RawRuntimeChunkNameFnCtx { | ||
name: name.to_string(), | ||
}) | ||
.await | ||
}) | ||
})), | ||
} | ||
} | ||
} |
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
Oops, something went wrong.