Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): hideTabBar时 屏幕高度 & 单端文件打包优化,去掉非本端文件
- Loading branch information
1 parent
b9e7f7f
commit fb67de2
Showing
9 changed files
with
155 additions
and
16 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
packages/mars-build/src/compiler/script/babel-plugin-script-post.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @file build | ||
* @author zhangjingyuan02 | ||
*/ | ||
|
||
/* eslint-disable fecs-camelcase */ | ||
/* eslint-disable babel/new-cap */ | ||
module.exports = function getVisitor(options = {}) { | ||
return ({types: t}) => { | ||
const { | ||
componentsInUsed | ||
} = options; | ||
return { | ||
visitor: { | ||
ImportDeclaration(path, state) { | ||
const sourcePath = path.node.source; | ||
if (sourcePath) { | ||
Object.keys(componentsInUsed).forEach(comp => { | ||
componentsInUsed[comp].declaration === sourcePath.value | ||
&& !componentsInUsed[comp].using | ||
&& path.remove(); | ||
}); | ||
} | ||
}, | ||
ObjectProperty(path, state) { | ||
if (path.node.key.name !== 'components') { | ||
return; | ||
} | ||
path.traverse({ | ||
ObjectProperty(path, state) { | ||
if (!componentsInUsed[path.node.key.name].using) { | ||
path.remove(); | ||
} | ||
} | ||
|
||
}); | ||
} | ||
} | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters