Open raozhanping opened 4 years ago
interface Compilation {
additionalChunkAssets: [];
assets: {
filename: {
children: [ RawSource, sourceMap ],
emited: boolean,
existsAt: string
}
},
assetsInfo: Map {
[filename]: {}
},
bail: any,
cache: {},
children: [ Compilation ],
childrenCounters: {},
chunkGroups: [ Entrypoint ],
chunkTemplate: ChunkTemplate {
hooks: {},
outputOptions: {},
_pluginCompat: SyncBailHook {}
},
chunks: [ Chunk ],
compilationDependencies: Set {},
compiler: Compiler {},
contextDependencies: Set {},
contextTimestamps: Map {},
dependencyFactories: Map {},
dependencyTemplates: Map {},
emittedAssets: Set {},
entries: [ MultiModule, NormalModule ],
entripoints: Map {
[name]: Entrypoint
},
errors: [],
fileDependencies: Set {},
fileTimestamps: Map {},
fulllHash: string,
hash: string,
hooks: {},
hotUpdateChunkTemplate: HotUpdateChunkTemplate {},
inpurtFileSystem: CachedInputFileSystem {},
logging: Map {},
mainTemplate: MainTemaplte {},
missingDependencies: Set {},
moduleTemplates: {},
modules: [ MultiModule | ContextModule | NormalModule],
name: any,
nameChunkGroups: Map {},
namedChunks: Map {},
options: {},
outputOptions: {},
performance: boolean,
profile: any,
records: {},
requestShortener: RequestShortener {},
resolverFactory: ResolverFactory {},
runtimeTemplate: RuntimeTemplate {},
semaphore: Semaphore {},
usedChunkIds: any,
usedModuleIds: any,
warnings: [],
_buildingModules: Map {},
_modules: Map {},
_pluginCompat: SyncBailHook {},
_prepareEntrypoints: [],
_rebuildingModules: Map {},
moduleTemplate: {}
}
🚀 hooks 调用顺序
正常字体 ➡️ compiler.hooks
hook
➡️ compilation.hooks hook ➡️ normalModuleFactory.hooks
addEntry
阶段调用 _addModuleChain 触发 moduleFactorybuildModule
紧接着调用 normalModule.buildfinishModules
seal
optimizeDependenciesBasic
beforeChunks
Complication
getStats
返回当前
compilation
的 Stats 对象addModule
将
module
添加到当前compilation
getModule
根据标记从当前
compilation
获取module
findModule
尝试通过标识符搜索
module
waitForBuildingFinished
当传入的
module
构建完成时执行回调callback
buildModule
构建传入的
module
processModuleDependencies
处理给定模块的依赖
addModuleDependencies
向模块添加依赖项。处理依赖关系后,由
processModuleDependencies
自动调用addEntry
添加
entry
到compilation
prefetch
用给定的依赖项创建一个模块
rebuildModule
触发模块重新构建
finish
完成
compilation
并且执行回调seal
密封编译并且执行回调
unseal
解开编译并且执行回调
reportDependencyErrorsAndWarnings
将给定模块的错误和警告信息添加到编译错误和警告中
addChunkInGroup
将模块添加到现有的chunkGroup或创建一个新的
addChunk
创建并添加一个新chunk到
compilation.chunks
assignDepth
给给定模块及其依赖分配
depth
getDependencyReference
返回给定模块的依赖项的引用
processDependenciesBlocksForChunkGroups
从
module
图创建chunk
图。这个过程分为两个阶段:chunkDependencies
中构建基本的块图processDependenciesBlocksForChunkGroups
将chunk
彼此连接,将Blocks
与Chunks
连接。当一个chunk
的所有模块都已经可用并且不需要连接块时,它将停止遍历removeReasonsOfDependencyBlock
删除模块与依赖块之间的关系
patchChunksAfterReasonRemoval
删除依赖项
reasons
后修补模块与块之间的关系removeChunkFromDependencies
在删除依赖的
reason
后 从给定的依赖块模块中删除给定的chunk
,由removeReasonOfDependencyBlock
自动调用addChunkInGroup
getPath
createChildCompiler
允许在 webpack 中运行webpack的另一个实例。但是是应用了不同的设置和配置的子实例。它从父级(或顶级编译器)赋值所有的钩子和插件,并创建一个子级
Compiler
实例emitAsset
updateAsset
getAssets
返回当前编译下所有资产的数组
getAsset
返回当前编译下给定名称的资产
sortItemsWithModuleIds
sortItemsWithChunkIds
summarizeDependencies
createHash
modifyHash
createModuleAssets
checkConstraints
createChunkAssets