提交 1e02476b 编写于 作者: Q qiang

fix: 解决开启 treeShaking 后 uni.previewImage 失效的问题 fixed #1168

上级 acdf149a
......@@ -31,6 +31,8 @@ const DEPS = {
['/platforms/h5/components/system-routes/open-location/index.vue', 'OpenLocation']
],
'previewImage': [
['/core/view/components/swiper/index.vue', 'Swiper'],
['/core/view/components/swiper-item/index.vue', 'SwiperItem'],
['/platforms/h5/components/system-routes/preview-image/index.vue', 'PreviewImage']
],
'showToast': TOAST_DEPS,
......@@ -138,4 +140,4 @@ module.exports = {
JSON.stringify(manifestJson, null, 4)
)
}
}
}
const fs = require('fs')
const path = require('path')
const updateComponents = require('./component')
const tmpDir = path.resolve(__dirname, '../../.tmp')
......@@ -72,6 +73,12 @@ function updateAppComponents(paths) {
return updateExportDefaultObject(paths, 'app-components.js', false)
}
function updateCoreComponents(paths){
const tags = process.UNI_TAGS || new Set()
Object.keys(paths).forEach(tag => tags.add(tag.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()))
updateComponents(tags)
}
function updateAppMixins(paths) {
return updateExportDefaultObject(paths, 'app-mixins.js', false, true)
}
......@@ -93,6 +100,11 @@ const isAppComponents = filepath => {
filepath.indexOf('/platforms/' + process.env.UNI_PLATFORM + '/components/app/') === 0
}
const isCoreComponents = filepath => {
return path.extname(filepath) === '.vue' &&
filepath.indexOf('/core/view/components/') === 0
}
const isAppMixins = filepath => {
return path.extname(filepath) === '.js' &&
filepath.indexOf('/platforms/' + process.env.UNI_PLATFORM + '/components/app/') === 0
......@@ -113,6 +125,7 @@ function parseDeps(apis, manifest) {
const apiProtocolPaths = Object.create(null)
const invokeApiPaths = Object.create(null)
const appComponentsPaths = Object.create(null)
const coreComponentsPaths = Object.create(null)
const appMixinsPaths = Object.create(null)
const systemRoutesPaths = Object.create(null)
const apiSubscribePaths = Object.create(null)
......@@ -126,6 +139,9 @@ function parseDeps(apis, manifest) {
}, {
test: isAppComponents,
paths: appComponentsPaths
}, {
test: isCoreComponents,
paths: coreComponentsPaths
}, {
test: isAppMixins,
paths: appMixinsPaths
......@@ -159,7 +175,7 @@ function parseDeps(apis, manifest) {
})
if (strategy) {
strategy.paths[exports] = filepath
} else {
} else {
console.log('dep',name,dep)
console.warn(`${filepath} 未识别`)
}
......@@ -175,6 +191,7 @@ function parseDeps(apis, manifest) {
apiProtocolPaths,
invokeApiPaths,
appComponentsPaths,
coreComponentsPaths,
appMixinsPaths,
systemRoutesPaths,
apiSubscribePaths
......@@ -203,6 +220,7 @@ module.exports = function updateApis(apis = new Set(), userApis = new Set()) {
invokeApiPaths,
apiSubscribePaths,
appComponentsPaths,
coreComponentsPaths,
appMixinsPaths,
systemRoutesPaths
} = parseDeps(apis, manifest)
......@@ -214,6 +232,7 @@ module.exports = function updateApis(apis = new Set(), userApis = new Set()) {
updateInvokeApi(invokeApiPaths)
updateAppComponents(appComponentsPaths)
updateCoreComponents(coreComponentsPaths)
updateAppMixins(appMixinsPaths)
updateSystemRoutes(systemRoutesPaths)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册