From 1e02476b375ad07a8c10b62366b1655bf0b6c9dc Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 9 Jan 2020 17:33:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=BC=80=E5=90=AF=20t?= =?UTF-8?q?reeShaking=20=E5=90=8E=20uni.previewImage=20=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20fixed=20#1168?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/manifest.js | 4 +++- .../packages/webpack-optimize-plugin/api.js | 23 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/build/manifest.js b/build/manifest.js index 30ffc626c..06bd8f7a2 100644 --- a/build/manifest.js +++ b/build/manifest.js @@ -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) ) } -} +} diff --git a/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js b/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js index 893b45f6b..b8191d442 100644 --- a/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js +++ b/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js @@ -1,5 +1,6 @@ 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) -} +} -- GitLab