Skip to content

perf: chunk js api #10502

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
145 changes: 73 additions & 72 deletions crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,63 @@ export declare class BuildInfo {
get _assets(): Assets
}

export declare class Chunk {
get name(): string | undefined
get id(): string | undefined
get ids(): Array<string>
get idNameHints(): Array<string>
get filenameTemplate(): string | undefined
get cssFilenameTemplate(): string | undefined
get _files(): Array<string>
get _runtime(): Array<string>
get hash(): string | undefined
get contentHash(): Record<string, string>
get renderedHash(): string | undefined
get chunkReason(): string | undefined
get _auxiliaryFiles(): Array<string>
isOnlyInitial(): boolean
canBeInitial(): boolean
hasRuntime(): boolean
getAllAsyncChunks(): Chunk[]
getAllInitialChunks(): Chunk[]
getAllReferencedChunks(): Chunk[]
get _groupsIterable(): ChunkGroup[]
getEntryOptions(): EntryOptionsDTO | undefined
}

export declare class ChunkGraph {
hasChunkEntryDependentChunks(chunk: Chunk): boolean
getChunkModules(chunk: Chunk): Module[]
getChunkModulesIterable(chunk: Chunk): Iterable<Module>
getChunkEntryModulesIterable(chunk: Chunk): Iterable<Module>
getNumberOfEntryModules(chunk: Chunk): number
getChunkEntryDependentChunksIterable(chunk: Chunk): Chunk[]
getChunkModulesIterableBySourceType(chunk: Chunk, sourceType: string): Module[]
getModuleChunks(module: Module): Chunk[]
getModuleId(module: Module): string | number | null
_getModuleHash(module: Module, runtime: string | string[] | undefined): string | null
getBlockChunkGroup(jsBlock: AsyncDependenciesBlock): ChunkGroup | null
}

export declare class ChunkGroup {
get chunks(): Chunk[]
get index(): number | undefined
get name(): string | undefined
get origins(): Array<JsChunkGroupOrigin>
get childrenIterable(): ChunkGroup[]
isInitial(): boolean
getParents(): ChunkGroup[]
getRuntimeChunk(): Chunk
getEntrypointChunk(): Chunk
getFiles(): Array<string>
getModulePreOrderIndex(module: Module): number | null
getModulePostOrderIndex(module: Module): number | null
}

export declare class Chunks {
get size(): number
_values(): JsChunk[]
_has(chunk: JsChunk): boolean
_values(): Chunk[]
_has(chunk: Chunk): boolean
}

export declare class CodeGenerationResult {
Expand Down Expand Up @@ -176,58 +229,6 @@ export declare class ExternalModule {
_emitFile(filename: string, source: JsCompatSource, assetInfo?: AssetInfo | undefined | null): void
}

export declare class JsChunk {
get name(): string | undefined
get id(): string | undefined
get ids(): Array<string>
get idNameHints(): Array<string>
get filenameTemplate(): string | undefined
get cssFilenameTemplate(): string | undefined
get files(): Array<string>
get runtime(): Array<string>
get hash(): string | undefined
get contentHash(): Record<string, string>
get renderedHash(): string | undefined
get chunkReason(): string | undefined
get auxiliaryFiles(): Array<string>
isOnlyInitial(): boolean
canBeInitial(): boolean
hasRuntime(): boolean
getAllAsyncChunks(): JsChunk[]
getAllInitialChunks(): JsChunk[]
getAllReferencedChunks(): JsChunk[]
groups(): JsChunkGroup[]
getEntryOptions(): EntryOptionsDTO | undefined
}

export declare class JsChunkGraph {
hasChunkEntryDependentChunks(chunk: JsChunk): boolean
getChunkModules(chunk: JsChunk): Module[]
getChunkEntryModules(chunk: JsChunk): Module[]
getNumberOfEntryModules(chunk: JsChunk): number
getChunkEntryDependentChunksIterable(chunk: JsChunk): JsChunk[]
getChunkModulesIterableBySourceType(chunk: JsChunk, sourceType: string): Module[]
getModuleChunks(module: Module): JsChunk[]
getModuleId(module: Module): string | number | null
getModuleHash(module: Module, runtime: string | string[] | undefined): string | null
getBlockChunkGroup(jsBlock: AsyncDependenciesBlock): JsChunkGroup | null
}

export declare class JsChunkGroup {
get chunks(): JsChunk[]
get index(): number | undefined
get name(): string | undefined
get origins(): Array<JsChunkGroupOrigin>
get childrenIterable(): JsChunkGroup[]
isInitial(): boolean
getParents(): JsChunkGroup[]
getRuntimeChunk(): JsChunk
getEntrypointChunk(): JsChunk
getFiles(): Array<string>
getModulePreOrderIndex(module: Module): number | null
getModulePostOrderIndex(module: Module): number | null
}

export declare class JsCompilation {
updateAsset(filename: string, newSourceOrFunction: JsCompatSource | ((source: JsCompatSourceOwned) => JsCompatSourceOwned), assetInfoUpdateOrFunction?: AssetInfo | ((assetInfo: AssetInfo) => AssetInfo | undefined)): void
getAssets(): Readonly<JsAsset>[]
Expand All @@ -238,18 +239,18 @@ export declare class JsCompilation {
getOptimizationBailout(): Array<JsStatsOptimizationBailout>
get chunks(): Chunks
getNamedChunkKeys(): Array<string>
getNamedChunk(name: string): JsChunk | null
getNamedChunk(name: string): Chunk
getNamedChunkGroupKeys(): Array<string>
getNamedChunkGroup(name: string): JsChunkGroup
getNamedChunkGroup(name: string): ChunkGroup
setAssetSource(name: string, source: JsCompatSource): void
deleteAssetSource(name: string): void
getAssetFilenames(): Array<string>
hasAsset(name: string): boolean
emitAsset(filename: string, source: JsCompatSource, assetInfo?: AssetInfo | undefined | null): void
deleteAsset(filename: string): void
renameAsset(filename: string, newName: string): void
get entrypoints(): JsChunkGroup[]
get chunkGroups(): JsChunkGroup[]
get entrypoints(): ChunkGroup[]
get chunkGroups(): ChunkGroup[]
get hash(): string | null
dependencies(): JsDependencies
pushDiagnostic(diagnostic: JsRspackDiagnostic): void
Expand All @@ -276,9 +277,9 @@ export declare class JsCompilation {
rebuildModule(moduleIdentifiers: Array<string>, f: any): void
importModule(request: string, layer: string | undefined | null, publicPath: JsFilename | undefined | null, baseUri: string | undefined | null, originalModule: string, originalModuleContext: string | undefined | null, callback: any): void
get entries(): JsEntries
addRuntimeModule(chunk: JsChunk, runtimeModule: JsAddingRuntimeModule): void
addRuntimeModule(chunk: Chunk, runtimeModule: JsAddingRuntimeModule): void
get moduleGraph(): JsModuleGraph
get chunkGraph(): JsChunkGraph
get chunkGraph(): ChunkGraph
addEntry(args: [string, EntryDependency, JsEntryOptions | undefined][], callback: (errMsg: Error | null, results: [string | null, Module][]) => void): void
addInclude(args: [string, EntryDependency, JsEntryOptions | undefined][], callback: (errMsg: Error | null, results: [string | null, Module][]) => void): void
get codeGenerationResults(): CodeGenerationResults
Expand Down Expand Up @@ -526,7 +527,7 @@ export interface JsAddingRuntimeModule {
}

export interface JsAdditionalTreeRuntimeRequirementsArg {
chunk: JsChunk
chunk: Chunk
runtimeRequirements: JsRuntimeGlobals
}

Expand Down Expand Up @@ -594,7 +595,7 @@ export interface JsAssetInfoRelated {

export interface JsBannerContentFnCtx {
hash: string
chunk: JsChunk
chunk: Chunk
filename: string
}

Expand Down Expand Up @@ -643,7 +644,7 @@ export interface JsCacheGroupTestCtx {
}

export interface JsChunkAssetArgs {
chunk: JsChunk
chunk: Chunk
filename: string
}

Expand All @@ -655,7 +656,7 @@ export interface JsChunkGroupOrigin {

export interface JsChunkOptionNameCtx {
module: Module
chunks: JsChunk[]
chunks: Chunk[]
cacheGroupKey: string
}

Expand Down Expand Up @@ -703,7 +704,7 @@ export interface JsCreateData {

export interface JsCreateScriptData {
code: string
chunk: JsChunk
chunk: Chunk
}

export interface JsDefaultObjectRedirectWarnObject {
Expand Down Expand Up @@ -847,12 +848,12 @@ export interface JsLibraryOptions {

export interface JsLinkPrefetchData {
code: string
chunk: JsChunk
chunk: Chunk
}

export interface JsLinkPreloadData {
code: string
chunk: JsChunk
chunk: Chunk
}

export interface JsLoaderContext {
Expand Down Expand Up @@ -1146,11 +1147,11 @@ export interface JsRuntimeModule {

export interface JsRuntimeModuleArg {
module: JsRuntimeModule
chunk: JsChunk
chunk: Chunk
}

export interface JsRuntimeRequirementInTreeArg {
chunk: JsChunk
chunk: Chunk
allRuntimeRequirements: JsRuntimeGlobals
runtimeRequirements: JsRuntimeGlobals
}
Expand Down Expand Up @@ -1530,7 +1531,7 @@ export interface RawAssetResourceGeneratorOptions {
}

export interface RawBannerPluginOptions {
banner: string | ((args: { hash: string, chunk: JsChunk, filename: string }) => string)
banner: string | ((args: { hash: string, chunk: Chunk, filename: string }) => string)
entryOnly?: boolean
footer?: boolean
raw?: boolean
Expand Down Expand Up @@ -2626,7 +2627,7 @@ export interface RegisterJsTaps {
registerCompilationAfterOptimizeModulesTaps: (stages: Array<number>) => Array<{ function: (() => void); stage: number; }>
registerCompilationOptimizeTreeTaps: (stages: Array<number>) => Array<{ function: (() => Promise<void>); stage: number; }>
registerCompilationOptimizeChunkModulesTaps: (stages: Array<number>) => Array<{ function: (() => Promise<boolean | undefined>); stage: number; }>
registerCompilationChunkHashTaps: (stages: Array<number>) => Array<{ function: ((arg: JsChunk) => Buffer); stage: number; }>
registerCompilationChunkHashTaps: (stages: Array<number>) => Array<{ function: ((arg: Chunk) => Buffer); stage: number; }>
registerCompilationChunkAssetTaps: (stages: Array<number>) => Array<{ function: ((arg: JsChunkAssetArgs) => void); stage: number; }>
registerCompilationProcessAssetsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsCompilation) => Promise<void>); stage: number; }>
registerCompilationAfterProcessAssetsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsCompilation) => void); stage: number; }>
Expand All @@ -2640,7 +2641,7 @@ export interface RegisterJsTaps {
registerNormalModuleFactoryCreateModuleTaps: (stages: Array<number>) => Array<{ function: ((arg: JsNormalModuleFactoryCreateModuleArgs) => Promise<void>); stage: number; }>
registerContextModuleFactoryBeforeResolveTaps: (stages: Array<number>) => Array<{ function: ((arg: false | JsContextModuleFactoryBeforeResolveData) => Promise<false | JsContextModuleFactoryBeforeResolveData>); stage: number; }>
registerContextModuleFactoryAfterResolveTaps: (stages: Array<number>) => Array<{ function: ((arg: false | JsContextModuleFactoryAfterResolveData) => Promise<false | JsContextModuleFactoryAfterResolveData>); stage: number; }>
registerJavascriptModulesChunkHashTaps: (stages: Array<number>) => Array<{ function: ((arg: JsChunk) => Buffer); stage: number; }>
registerJavascriptModulesChunkHashTaps: (stages: Array<number>) => Array<{ function: ((arg: Chunk) => Buffer); stage: number; }>
registerHtmlPluginBeforeAssetTagGenerationTaps: (stages: Array<number>) => Array<{ function: ((arg: JsBeforeAssetTagGenerationData) => JsBeforeAssetTagGenerationData); stage: number; }>
registerHtmlPluginAlterAssetTagsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsAlterAssetTagsData) => JsAlterAssetTagsData); stage: number; }>
registerHtmlPluginAlterAssetTagGroupsTaps: (stages: Array<number>) => Array<{ function: ((arg: JsAlterAssetTagGroupsData) => JsAlterAssetTagGroupsData); stage: number; }>
Expand Down
Loading
Loading