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

fix(h5): optimize with map

上级 eb3f640c
const path = require('path')
const {
normalizePath
} = require('@dcloudio/uni-cli-shared')
process.UNI_APIS = new Set()
const sourcePath = normalizePath(path.join(require.resolve('@dcloudio/uni-h5'), '../../'))
module.exports = function ({
types: t
}) {
......@@ -21,10 +12,6 @@ module.exports = function ({
path.node.object.name === 'wx'
)
) {
if (normalizePath(state.file.opts.filename).indexOf(sourcePath) === 0) {
path.stop()
return
}
process.UNI_APIS.add(path.node.property.name || path.node.property.value)
}
}
......
......@@ -118,7 +118,7 @@ const isApiSubscribe = filepath => {
return filepath.indexOf('/core/view/bridge/subscribe/api') === 0
}
function parseDeps (apis, manifest) {
function parseDeps (apis, manifest) {
const apiPaths = Object.create(null)
const apiProtocolPaths = Object.create(null)
const invokeApiPaths = Object.create(null)
......@@ -196,7 +196,7 @@ function parseDeps (apis, manifest) {
}
}
module.exports = function updateApis (apis = new Set(), userApis = new Set()) {
module.exports = function updateApis (apis = new Set(), userApis = new Set()) {
if (!fs.existsSync(tmpDir)) {
fs.mkdirSync(tmpDir)
}
......@@ -211,6 +211,15 @@ module.exports = function updateApis (apis = new Set(), userApis = new Set()) {
apis = new Set([...apis, ...userApis])
if (process.UNI_TAGS) {
// TODO 临时硬编码
if (process.UNI_TAGS.has('map')) {
apis.add('getLocation')
apis.add('stopCompass')
apis.add('onCompassChange')
}
}
const {
apiPaths,
apiProtocolPaths,
......@@ -232,4 +241,4 @@ module.exports = function updateApis (apis = new Set(), userApis = new Set()) {
updateCoreComponents(coreComponentsPaths)
updateAppMixins(appMixinsPaths)
updateSystemRoutes(systemRoutesPaths)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册