@@ -232,76 +232,7 @@ tap 是监听注册事件、call 是执行事件
232232插件入口 apply 函数的执行过程如下图所示:
233233有个大概印象即可,后文继续看具体代码实现。
234234
235- ``` mermaid
236- graph TD
237- A[TaroMiniPlugin webpack 插件 apply 方法] --> B[初始化上下文和入口文件]
238- B --> C{解构配置选项}
239- C --> D[注册 run 钩子]
240- C --> E[注册 watchRun 钩子]
241- C --> F[注册 make 钩子]
242- C --> G[注册 compilation 钩子]
243- C --> H[注册 afterEmit 钩子]
244- C --> I[应用 TaroNormalModulesPlugin]
245- C --> J{newBlended 模式}
246- J --> K[添加加载块插件]
247-
248- D --> L[执行 run 方法]
249- L --> M[应用 TaroLoadChunksPlugin]
250-
251- E --> N[获取已修改文件]
252- N --> O{文件有变更}
253- O --> P[设置 isWatch 为 true]
254- E --> Q[执行 run 方法]
255- Q --> R{loadChunksPlugin 是否存在}
256- R --> S[应用 TaroLoadChunksPlugin]
257-
258- F --> T[处理依赖项]
259- T --> U[编译独立页面]
260- T --> V[添加依赖项到 compilation]
261- V --> W[调用 onCompilerMake 回调]
262-
263- G --> X[设置依赖工厂]
264- G --> Y[插入 Taro Loader]
265- G --> Z[注册 processAssets 钩子]
266- Z --> AA[生成独立分包文件]
267- Z --> AB[生成小程序文件]
268- Z --> AC[优化小程序文件]
269- Z --> AD[调用 modifyBuildAssets 回调]
270-
271- H --> AE[添加 tabbar 文件到依赖中]
272-
273- style A fill:#f9f,stroke:#333,stroke-width:4px
274- style B fill:#bbf,stroke:#333,stroke-width:2px
275- style C fill:#bbf,stroke:#333,stroke-width:2px
276- style D fill:#bbf,stroke:#333,stroke-width:2px
277- style E fill:#bbf,stroke:#333,stroke-width:2px
278- style F fill:#bbf,stroke:#333,stroke-width:2px
279- style G fill:#bbf,stroke:#333,stroke-width:2px
280- style H fill:#bbf,stroke:#333,stroke-width:2px
281- style I fill:#bbf,stroke:#333,stroke-width:2px
282- style J fill:#bbf,stroke:#333,stroke-width:2px
283- style K fill:#bbf,stroke:#333,stroke-width:2px
284- style L fill:#bbf,stroke:#333,stroke-width:2px
285- style M fill:#bbf,stroke:#333,stroke-width:2px
286- style N fill:#bbf,stroke:#333,stroke-width:2px
287- style O fill:#bbf,stroke:#333,stroke-width:2px
288- style P fill:#bbf,stroke:#333,stroke-width:2px
289- style Q fill:#bbf,stroke:#333,stroke-width:2px
290- style R fill:#bbf,stroke:#333,stroke-width:2px
291- style S fill:#bbf,stroke:#333,stroke-width:2px
292- style T fill:#bbf,stroke:#333,stroke-width:2px
293- style U fill:#bbf,stroke:#333,stroke-width:2px
294- style V fill:#bbf,stroke:#333,stroke-width:2px
295- style W fill:#bbf,stroke:#333,stroke-width:2px
296- style X fill:#bbf,stroke:#333,stroke-width:2px
297- style Y fill:#bbf,stroke:#333,stroke-width:2px
298- style Z fill:#bbf,stroke:#333,stroke-width:2px
299- style AA fill:#bbf,stroke:#333,stroke-width:2px
300- style AB fill:#bbf,stroke:#333,stroke-width:2px
301- style AC fill:#bbf,stroke:#333,stroke-width:2px
302- style AD fill:#bbf,stroke:#333,stroke-width:2px
303- style AE fill:#bbf,stroke:#333,stroke-width:2px
304- ```
235+ ![ TaroMiniPlugin webpack 插件 apply 方法] ( ./images/apply.svg )
305236
306237## 4. 注册 compiler.hooks.run 钩子
307238
0 commit comments