'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const CopyOuterComponentsForIndependent = require('./copy-outer-components-for-independent');
const CopyWxComponentOnDemand = require('./copy-wx-components-on-demand');
 
// @dcloudio/webpack-uni-mp-loader/lib/plugin/index-new.js
// 需要在在上述插件之后执行(获取处理过的json
class DependencyAnalyze {
    // wxComponentDependencyAnalyzeHandle 分析微信原生组件的依赖情况
    // 后面单独建一个仓库时,指定该类的协议,如需要提供getDepsByComponents方法
    constructor () {
        this.AnalyzeWxcomponentDependency = require('../../analyze-wxcomponent-dependency/index')
    }
 
    init (emitFileMap, compilation) {
        const manifestConfig = process.UNI_MANIFEST;
        const weixinConfig = manifestConfig['mp-weixin'] || {};
        const independentSwitch = !!weixinConfig.independent;
        const copyWxComponentsOnDemandSwitch = !!weixinConfig.copyWxComponentsOnDemand; // 默认值false
 
        if (copyWxComponentsOnDemandSwitch) { // 开启按需复制
            new CopyWxComponentOnDemand(emitFileMap, this.AnalyzeWxcomponentDependency, compilation).init();
        }
 
        if (independentSwitch) {
            new CopyOuterComponentsForIndependent(emitFileMap, this.AnalyzeWxcomponentDependency, compilation).init();
        }
    }
}
 
module.exports = DependencyAnalyze;