Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add rsdoctor native plugin #8930

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ rspack_plugin_progress = { version = "0.2.0", path = "crates/rsp
rspack_plugin_real_content_hash = { version = "0.2.0", path = "crates/rspack_plugin_real_content_hash" }
rspack_plugin_remove_duplicate_modules = { version = "0.2.0", path = "crates/rspack_plugin_remove_duplicate_modules" }
rspack_plugin_remove_empty_chunks = { version = "0.2.0", path = "crates/rspack_plugin_remove_empty_chunks" }
rspack_plugin_rsdoctor = { version = "0.2.0", path = "crates/rspack_plugin_rsdoctor" }
rspack_plugin_runtime = { version = "0.2.0", path = "crates/rspack_plugin_runtime" }
rspack_plugin_runtime_chunk = { version = "0.2.0", path = "crates/rspack_plugin_runtime_chunk" }
rspack_plugin_schemes = { version = "0.2.0", path = "crates/rspack_plugin_schemes" }
Expand Down
1 change: 1 addition & 0 deletions crates/node_binding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ rspack_napi = { workspace = true }
rspack_paths = { workspace = true }
rspack_plugin_html = { workspace = true }
rspack_plugin_javascript = { workspace = true }
rspack_plugin_rsdoctor = { workspace = true }
rspack_util = { workspace = true }

rspack_tracing = { workspace = true }
Expand Down
169 changes: 168 additions & 1 deletion crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ export declare enum BuiltinPluginName {
LightningCssMinimizerRspackPlugin = 'LightningCssMinimizerRspackPlugin',
BundlerInfoRspackPlugin = 'BundlerInfoRspackPlugin',
CssExtractRspackPlugin = 'CssExtractRspackPlugin',
RsdoctorPlugin = 'RsdoctorPlugin',
JsLoaderRspackPlugin = 'JsLoaderRspackPlugin',
LazyCompilationPlugin = 'LazyCompilationPlugin'
}
Expand Down Expand Up @@ -813,6 +814,157 @@ export interface JsResourceData {
fragment?: string
}

export interface JsRsdoctorAsset {
ukey: number
path: string
chunks: Array<number>
size: number
}

export interface JsRsdoctorAssetPatch {
assets: Array<JsRsdoctorAsset>
chunkAssets: Array<JsRsdoctorChunkAssets>
entrypointAssets: Array<JsRsdoctorEntrypointAssets>
}

export interface JsRsdoctorChunk {
ukey: number
name: string
initial: boolean
entry: boolean
dependencies: Array<number>
imported: Array<number>
}

export interface JsRsdoctorChunkAssets {
chunk: number
assets: Array<number>
}

export interface JsRsdoctorChunkGraph {
chunks: Array<JsRsdoctorChunk>
entrypoints: Array<JsRsdoctorEntrypoint>
}

export interface JsRsdoctorChunkModules {
chunk: number
modules: Array<number>
}

export interface JsRsdoctorDependency {
ukey: number
kind: string
request: string
module: number
dependency: number
}

export interface JsRsdoctorEntrypoint {
ukey: number
name: string
chunks: Array<number>
}

export interface JsRsdoctorEntrypointAssets {
entrypoint: number
assets: Array<number>
}

export interface JsRsdoctorExportInfo {
ukey: number
name: string
from?: number
variable?: number
identifier?: JsRsdoctorStatement
sideEffects: Array<number>
}

export interface JsRsdoctorModule {
ukey: number
identifier: string
path: string
isEntry: boolean
kind: 'normal' | 'concatenated'
layer?: string
dependencies: Array<number>
imported: Array<number>
modules: Array<number>
belongModules: Array<number>
chunks: Array<number>
}

export interface JsRsdoctorModuleGraph {
modules: Array<JsRsdoctorModule>
dependencies: Array<JsRsdoctorDependency>
chunkModules: Array<JsRsdoctorChunkModules>
}

export interface JsRsdoctorModuleGraphModule {
ukey: number
module: number
exports: Array<number>
sideEffects: Array<number>
variables: Array<number>
dynamic: boolean
}

export interface JsRsdoctorModuleId {
module: number
renderId: string
}

export interface JsRsdoctorModuleIdsPatch {
moduleIds: Array<JsRsdoctorModuleId>
}

export interface JsRsdoctorModuleOriginalSource {
module: number
source: string
size: number
}

export interface JsRsdoctorModuleSourcesPatch {
moduleOriginalSources: Array<JsRsdoctorModuleOriginalSource>
}

export interface JsRsdoctorSideEffect {
ukey: number
name: string
originName?: string
module: number
identifier: JsRsdoctorStatement
isNameSpace: boolean
fromDependency?: number
exports: Array<number>
variable?: number
}

export interface JsRsdoctorSourcePosition {
line?: number
column?: number
index?: number
}

export interface JsRsdoctorSourceRange {
start: JsRsdoctorSourcePosition
end?: JsRsdoctorSourcePosition
}

export interface JsRsdoctorStatement {
module: number
sourcePosition?: JsRsdoctorSourceRange
transformedPosition: JsRsdoctorSourceRange
}

export interface JsRsdoctorVariable {
ukey: number
name: string
module: number
usedInfo: string
identififer: JsRsdoctorStatement
exported?: number
}

export interface JsRspackDiagnostic {
severity: JsRspackSeverity
error: JsRspackError
Expand Down Expand Up @@ -1947,6 +2099,11 @@ export interface RawResolveTsconfigOptions {
references?: Array<string>
}

export interface RawRsdoctorPluginOptions {
moduleGraphFeatures: boolean | Array<'graph' | 'ids' | 'sources'>
chunkGraphFeatures: boolean | Array<'graph' | 'assets'>
}

export interface RawRspackFuture {

}
Expand Down Expand Up @@ -2117,7 +2274,12 @@ export declare enum RegisterJsTapKind {
HtmlPluginAlterAssetTagGroups = 37,
HtmlPluginAfterTemplateExecution = 38,
HtmlPluginBeforeEmit = 39,
HtmlPluginAfterEmit = 40
HtmlPluginAfterEmit = 40,
RsdoctorPluginModuleGraph = 41,
RsdoctorPluginChunkGraph = 42,
RsdoctorPluginModuleIds = 43,
RsdoctorPluginModuleSources = 44,
RsdoctorPluginAssets = 45
}

export interface RegisterJsTaps {
Expand Down Expand Up @@ -2162,6 +2324,11 @@ export interface RegisterJsTaps {
registerHtmlPluginAfterTemplateExecutionTaps: (stages: Array<number>) => Array<{ function: ((arg: JsAfterTemplateExecutionData) => JsAfterTemplateExecutionData); stage: number; }>
registerHtmlPluginBeforeEmitTaps: (stages: Array<number>) => Array<{ function: ((arg: JsBeforeEmitData) => JsBeforeEmitData); stage: number; }>
registerHtmlPluginAfterEmitTaps: (stages: Array<number>) => Array<{ function: ((arg: JsAfterEmitData) => JsAfterEmitData); stage: number; }>
registerRsdoctorPluginModuleGraphTaps: (stages: Array<number>) => Array<{ function: ((arg: JsRsdoctorModuleGraph) => Promise<boolean | undefined>); stage: number; }>
registerRsdoctorPluginChunkGraphTaps: (stages: Array<number>) => Array<{ function: ((arg: JsRsdoctorChunkGraph) => Promise<boolean | undefined>); stage: number; }>
registerRsdoctorPluginModuleIdsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsRsdoctorModuleIdsPatch) => Promise<boolean | undefined>); stage: number; }>
registerRsdoctorPluginModuleSourcesTaps: (stages: Array<number>) => Array<{ function: ((arg: JsRsdoctorModuleSourcesPatch) => Promise<boolean | undefined>); stage: number; }>
registerRsdoctorPluginAssetsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsRsdoctorAssetPatch) => Promise<boolean | undefined>); stage: number; }>
}

export interface ThreadsafeNodeFS {
Expand Down
Loading
Loading