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

fix(h5): Make sure components and apis are imported in the same order when tree shaking (#3611)

上级 cf3fb5db
......@@ -102,7 +102,8 @@ const isAppComponents = filepath => {
const isCoreComponents = filepath => {
return path.extname(filepath) === '.vue' &&
(filepath.indexOf('/core/view/components/') === 0 || filepath.indexOf('/platforms/' + process.env.UNI_PLATFORM + '/view/components/') === 0)
(filepath.indexOf('/core/view/components/') === 0 || filepath.indexOf('/platforms/' + process.env.UNI_PLATFORM +
'/view/components/') === 0)
}
const isAppMixins = filepath => {
......@@ -149,8 +150,10 @@ function parseDeps (apis, manifest) {
}, {
test: isApiSubscribe,
paths: apiSubscribePaths
}]
for (const name of apis.values()) {
}]
// 固定顺序,避免因顺序的变化导致内容变化,从而生成不同的 hash 文件名
const apiNames = [...apis].sort()
for (const name of apiNames) {
const options = manifest[name]
if (Array.isArray(options)) {
apiPaths[name] = options[0]
......@@ -241,4 +244,4 @@ module.exports = function updateApis (apis = new Set(), userApis = new Set()) {
updateCoreComponents(coreComponentsPaths)
updateAppMixins(appMixinsPaths)
updateSystemRoutes(systemRoutesPaths)
}
}
......@@ -25,7 +25,7 @@ module.exports = function updateComponents (tags) {
autoloadTags.other[tagName].forEach(tag => tags.add(tag))
}
})
tags = [...tags]
tags = [...tags].sort() // 固定顺序,避免因顺序的变化导致内容变化,从而生成不同的 hash 文件名
const importsStr = tags.map(tagName => {
if (platformTags.indexOf(tagName) !== -1) {
return `import ${capitalize(camelize(tagName))} from 'uni-platform/view/components/${tagName}'`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册