Files
2025-11-14 11:39:33 +08:00

30 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;