-
-
Notifications
You must be signed in to change notification settings - Fork 601
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
1 parent
b65177b
commit 9763310
Showing
14 changed files
with
542 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,5 +42,6 @@ | |
"tokio", | ||
"ukey", | ||
"Ukey" | ||
] | ||
], | ||
"rust-analyzer.checkOnSave": true | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
mod context_replacement; | ||
mod js_loader; | ||
mod rsdoctor; | ||
|
||
pub use context_replacement::*; | ||
pub(super) use js_loader::{JsLoaderRspackPlugin, JsLoaderRunner}; | ||
pub mod buildtime_plugins; | ||
pub use rsdoctor::*; |
314 changes: 314 additions & 0 deletions
314
crates/rspack_binding_values/src/plugins/rsdoctor/data.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,314 @@ | ||
use napi_derive::napi; | ||
use rspack_plugin_rsdoctor::{ | ||
RsdoctorAsset, RsdoctorChunk, RsdoctorChunkGraph, RsdoctorDependency, RsdoctorEntrypoint, | ||
RsdoctorExportInfo, RsdoctorModule, RsdoctorModuleGraph, RsdoctorModuleGraphModule, | ||
RsdoctorModuleSource, RsdoctorSideEffect, RsdoctorSourcePosition, RsdoctorSourceRange, | ||
RsdoctorStatement, RsdoctorVariable, | ||
}; | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorModule { | ||
pub ukey: i32, | ||
pub identifier: String, | ||
pub path: String, | ||
pub is_entry: bool, | ||
pub kind: String, | ||
pub layer: Option<String>, | ||
pub dependencies: Vec<i32>, | ||
pub imported: Vec<i32>, | ||
pub modules: Vec<i32>, | ||
pub chunks: Vec<i32>, | ||
} | ||
|
||
impl From<RsdoctorModule> for JsRsdoctorModule { | ||
fn from(value: RsdoctorModule) -> Self { | ||
JsRsdoctorModule { | ||
ukey: value.ukey as i32, | ||
identifier: value.identifier.to_string(), | ||
path: value.path, | ||
is_entry: value.is_entry, | ||
kind: value.kind.into(), | ||
layer: value.layer, | ||
dependencies: value.dependencies.into_iter().map(|d| d as i32).collect(), | ||
imported: value.imported.into_iter().map(|d| d as i32).collect(), | ||
modules: value.modules.into_iter().map(|d| d as i32).collect(), | ||
chunks: value.chunks.into_iter().map(|d| d as i32).collect(), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorDependency { | ||
pub ukey: i32, | ||
pub kind: String, | ||
pub request: String, | ||
pub module: i32, | ||
pub dependency: i32, | ||
} | ||
|
||
impl From<RsdoctorDependency> for JsRsdoctorDependency { | ||
fn from(value: RsdoctorDependency) -> Self { | ||
JsRsdoctorDependency { | ||
ukey: value.ukey as i32, | ||
kind: value.kind.to_string(), | ||
request: value.request, | ||
module: value.module as i32, | ||
dependency: value.dependency as i32, | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorChunk { | ||
pub ukey: i32, | ||
pub name: String, | ||
pub initial: bool, | ||
pub entry: bool, | ||
pub assets: Vec<i32>, | ||
pub dependencies: Vec<i32>, | ||
pub imported: Vec<i32>, | ||
} | ||
|
||
impl From<RsdoctorChunk> for JsRsdoctorChunk { | ||
fn from(value: RsdoctorChunk) -> Self { | ||
JsRsdoctorChunk { | ||
ukey: value.ukey as i32, | ||
name: value.name, | ||
initial: value.initial, | ||
entry: value.entry, | ||
assets: value.assets.into_iter().map(|d| d as i32).collect(), | ||
dependencies: value.dependencies.into_iter().map(|d| d as i32).collect(), | ||
imported: value.imported.into_iter().map(|d| d as i32).collect(), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorEntrypoint { | ||
pub ukey: i32, | ||
pub name: String, | ||
pub chunks: Vec<i32>, | ||
} | ||
|
||
impl From<RsdoctorEntrypoint> for JsRsdoctorEntrypoint { | ||
fn from(value: RsdoctorEntrypoint) -> Self { | ||
JsRsdoctorEntrypoint { | ||
ukey: value.ukey as i32, | ||
name: value.name, | ||
chunks: value.chunks.into_iter().map(|d| d as i32).collect(), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorAsset { | ||
pub ukey: i32, | ||
pub path: String, | ||
pub chunks: Vec<i32>, | ||
} | ||
|
||
impl From<RsdoctorAsset> for JsRsdoctorAsset { | ||
fn from(value: RsdoctorAsset) -> Self { | ||
JsRsdoctorAsset { | ||
ukey: value.ukey as i32, | ||
path: value.path, | ||
chunks: value.chunks.into_iter().map(|d| d as i32).collect(), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorModuleSource { | ||
pub source_size: i32, | ||
pub transform_size: i32, | ||
pub source: Option<String>, | ||
pub source_map: Option<String>, | ||
} | ||
|
||
impl From<RsdoctorModuleSource> for JsRsdoctorModuleSource { | ||
fn from(value: RsdoctorModuleSource) -> Self { | ||
JsRsdoctorModuleSource { | ||
source_size: value.source_size as i32, | ||
transform_size: value.transform_size as i32, | ||
source: value.source, | ||
source_map: value.source_map, | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorModuleGraphModule { | ||
pub ukey: i32, | ||
pub module: i32, | ||
pub exports: Vec<i32>, | ||
pub side_effects: Vec<i32>, | ||
pub variables: Vec<i32>, | ||
pub dynamic: bool, | ||
} | ||
|
||
impl From<RsdoctorModuleGraphModule> for JsRsdoctorModuleGraphModule { | ||
fn from(value: RsdoctorModuleGraphModule) -> Self { | ||
JsRsdoctorModuleGraphModule { | ||
ukey: value.ukey as i32, | ||
module: value.module as i32, | ||
exports: value.exports.into_iter().map(|d| d as i32).collect(), | ||
side_effects: value.side_effects.into_iter().map(|d| d as i32).collect(), | ||
variables: value.variables.into_iter().map(|d| d as i32).collect(), | ||
dynamic: value.dynamic, | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorSideEffect { | ||
pub ukey: i32, | ||
pub name: String, | ||
pub origin_name: Option<String>, | ||
pub module: i32, | ||
pub identifier: JsRsdoctorStatement, | ||
pub is_name_space: bool, | ||
pub from_dependency: Option<i32>, | ||
pub exports: Vec<i32>, | ||
pub variable: Option<i32>, | ||
} | ||
|
||
impl From<RsdoctorSideEffect> for JsRsdoctorSideEffect { | ||
fn from(value: RsdoctorSideEffect) -> Self { | ||
JsRsdoctorSideEffect { | ||
ukey: value.ukey as i32, | ||
name: value.name, | ||
origin_name: value.origin_name, | ||
module: value.module as i32, | ||
identifier: value.identifier.into(), | ||
is_name_space: value.is_name_space, | ||
from_dependency: value.from_dependency.map(|d| d as i32), | ||
exports: value.exports.into_iter().map(|d| d as i32).collect(), | ||
variable: value.variable.map(|d| d as i32), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorVariable { | ||
pub ukey: i32, | ||
pub name: String, | ||
pub module: i32, | ||
pub used_info: String, | ||
pub identififer: JsRsdoctorStatement, | ||
pub exported: Option<i32>, | ||
} | ||
|
||
impl From<RsdoctorVariable> for JsRsdoctorVariable { | ||
fn from(value: RsdoctorVariable) -> Self { | ||
JsRsdoctorVariable { | ||
ukey: value.ukey as i32, | ||
name: value.name, | ||
module: value.module as i32, | ||
used_info: value.used_info, | ||
identififer: value.identififer.into(), | ||
exported: value.exported.map(|d| d as i32), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorExportInfo { | ||
pub ukey: i32, | ||
pub name: String, | ||
pub from: Option<i32>, | ||
pub variable: Option<i32>, | ||
pub identifier: Option<JsRsdoctorStatement>, | ||
pub side_effects: Vec<i32>, | ||
} | ||
|
||
impl From<RsdoctorExportInfo> for JsRsdoctorExportInfo { | ||
fn from(value: RsdoctorExportInfo) -> Self { | ||
JsRsdoctorExportInfo { | ||
ukey: value.ukey as i32, | ||
name: value.name, | ||
from: value.from.map(|d| d as i32), | ||
variable: value.variable.map(|d| d as i32), | ||
identifier: value.identifier.map(|i| i.into()), | ||
side_effects: value.side_effects.into_iter().map(|d| d as i32).collect(), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorStatement { | ||
pub module: i32, | ||
pub source_position: Option<JsRsdoctorSourceRange>, | ||
pub transformed_position: JsRsdoctorSourceRange, | ||
} | ||
|
||
impl From<RsdoctorStatement> for JsRsdoctorStatement { | ||
fn from(value: RsdoctorStatement) -> Self { | ||
JsRsdoctorStatement { | ||
module: value.module as i32, | ||
source_position: value.source_position.map(|p| p.into()), | ||
transformed_position: value.transformed_position.into(), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorSourceRange { | ||
pub start: JsRsdoctorSourcePosition, | ||
pub end: Option<JsRsdoctorSourcePosition>, | ||
} | ||
|
||
impl From<RsdoctorSourceRange> for JsRsdoctorSourceRange { | ||
fn from(value: RsdoctorSourceRange) -> Self { | ||
JsRsdoctorSourceRange { | ||
start: value.start.into(), | ||
end: value.end.map(|p| p.into()), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorSourcePosition { | ||
pub line: Option<i32>, | ||
pub column: Option<i32>, | ||
pub index: Option<i32>, | ||
} | ||
|
||
impl From<RsdoctorSourcePosition> for JsRsdoctorSourcePosition { | ||
fn from(value: RsdoctorSourcePosition) -> Self { | ||
JsRsdoctorSourcePosition { | ||
line: value.line.map(|l| l as i32), | ||
column: value.column.map(|c| c as i32), | ||
index: value.index.map(|i| i as i32), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorModuleGraph { | ||
pub modules: Vec<JsRsdoctorModule>, | ||
pub dependencies: Vec<JsRsdoctorDependency>, | ||
} | ||
|
||
impl From<RsdoctorModuleGraph> for JsRsdoctorModuleGraph { | ||
fn from(value: RsdoctorModuleGraph) -> Self { | ||
JsRsdoctorModuleGraph { | ||
modules: value.modules.into_iter().map(|m| m.into()).collect(), | ||
dependencies: value.dependencies.into_iter().map(|d| d.into()).collect(), | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct JsRsdoctorChunkGraph { | ||
pub chunks: Vec<JsRsdoctorChunk>, | ||
pub entrypoints: Vec<JsRsdoctorEntrypoint>, | ||
} | ||
|
||
impl From<RsdoctorChunkGraph> for JsRsdoctorChunkGraph { | ||
fn from(value: RsdoctorChunkGraph) -> Self { | ||
JsRsdoctorChunkGraph { | ||
chunks: value.chunks.into_iter().map(|c| c.into()).collect(), | ||
entrypoints: value.entrypoints.into_iter().map(|e| e.into()).collect(), | ||
} | ||
} | ||
} |
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,5 @@ | ||
mod data; | ||
mod options; | ||
|
||
pub use data::*; | ||
pub use options::*; |
Oops, something went wrong.