提交 f8e1cc20 编写于 作者: fxy060608's avatar fxy060608

fix(h5): easycom with tree shaking

上级 727408cc
...@@ -35,7 +35,13 @@ const { ...@@ -35,7 +35,13 @@ const {
module.exports = { module.exports = {
compile (source, options = {}) { compile (source, options = {}) {
if ( // 启用摇树优化后,需要过滤内置组件
!options.autoComponentResourcePath ||
options.autoComponentResourcePath.indexOf('@dcloudio/uni-h5/src') === -1
) {
(options.modules || (options.modules = [])).push(autoComponentsModule) (options.modules || (options.modules = [])).push(autoComponentsModule)
}
options.isUnaryTag = isUnaryTag options.isUnaryTag = isUnaryTag
// 将 autoComponents 挂在 isUnaryTag 上边 // 将 autoComponents 挂在 isUnaryTag 上边
options.isUnaryTag.autoComponents = new Set() options.isUnaryTag.autoComponents = new Set()
......
...@@ -77,8 +77,13 @@ module.exports = function (source) { ...@@ -77,8 +77,13 @@ module.exports = function (source) {
if (options.isH5TreeShaking) { // 摇树优化逻辑(框架组件移除样式,禁用 modules) if (options.isH5TreeShaking) { // 摇树优化逻辑(框架组件移除样式,禁用 modules)
const isWin = /^win/.test(process.platform) const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
if(options.compilerOptions){
options.compilerOptions = {}
}
options.compilerOptions.autoComponentResourcePath = normalizePath(resourcePath)
// fixed by xxxxxx // fixed by xxxxxx
if(!modules && options.compilerOptions && options.compilerOptions.modules){ if(!modules && options.compilerOptions && options.compilerOptions.modules){
modules = options.compilerOptions.modules modules = options.compilerOptions.modules
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册