Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
20岁爱吃必胜客
uni-app
提交
ef4f0fc4
U
uni-app
项目概览
20岁爱吃必胜客
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ef4f0fc4
编写于
4月 11, 2022
作者:
S
songyu
提交者:
折腾笔记
4月 11, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 代码格式化
上级
1b44dd92
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
100 addition
and
103 deletion
+100
-103
packages/uni-cli-shared/lib/cache.js
packages/uni-cli-shared/lib/cache.js
+4
-4
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+6
-7
packages/uni-mp-weixin/lib/createIndependentPlugin.js
packages/uni-mp-weixin/lib/createIndependentPlugin.js
+32
-32
packages/uni-mp-weixin/lib/uni.config.js
packages/uni-mp-weixin/lib/uni.config.js
+5
-5
packages/vue-cli-plugin-uni/lib/mp/index.js
packages/vue-cli-plugin-uni/lib/mp/index.js
+1
-1
packages/vue-cli-plugin-uni/lib/split-chunks.js
packages/vue-cli-plugin-uni/lib/split-chunks.js
+8
-8
packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
...es/webpack-uni-mp-loader/lib/plugin/generate-component.js
+2
-2
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
+42
-44
未找到文件。
packages/uni-cli-shared/lib/cache.js
浏览文件 @
ef4f0fc4
...
...
@@ -104,12 +104,12 @@ function updateComponentJson (name, jsonObj, usingComponents = true, type = 'Com
}
function
updateUsingGlobalComponents
(
name
,
usingGlobalComponents
)
{
const
manifestConfig
=
process
.
UNI_MANIFEST
;
const
weixinConfig
=
manifestConfig
[
'
mp-weixin
'
]
;
const
independentSwitch
=
!!
weixinConfig
.
independent
;
const
manifestConfig
=
process
.
UNI_MANIFEST
const
weixinConfig
=
manifestConfig
[
'
mp-weixin
'
]
const
independentSwitch
=
!!
weixinConfig
.
independent
if
(
!
independentSwitch
&&
supportGlobalUsingComponents
)
{
return
;
return
}
const
oldJsonStr
=
getJsonFile
(
name
)
...
...
packages/uni-cli-shared/lib/pages.js
浏览文件 @
ef4f0fc4
...
...
@@ -209,20 +209,19 @@ function parseEntry (pagesJson) {
process
.
UNI_ENTRY
=
{
'
common/main
'
:
mainJsPath
}
const
manifestConfig
=
process
.
UNI_MANIFEST
;
const
weixinConfig
=
manifestConfig
[
'
mp-weixin
'
]
||
{}
;
const
independentSwitch
=
!!
weixinConfig
.
independent
;
const
manifestConfig
=
process
.
UNI_MANIFEST
const
weixinConfig
=
manifestConfig
[
'
mp-weixin
'
]
||
{}
const
independentSwitch
=
!!
weixinConfig
.
independent
if
(
independentSwitch
)
{
Object
.
values
(
process
.
UNI_SUBPACKAGES
).
forEach
(({
root
,
independent
=
false
})
=>
{
if
(
root
&&
independent
)
{
const
pkgRootMainJsKey
=
`
${
root
}
/common/main`
;
const
pkgRootMainJsKey
=
`
${
root
}
/common/main`
// const pkgRootMainJsPath = `${process.env.UNI_INPUT_DIR}/${root}/main.js`;
process
.
UNI_ENTRY
[
pkgRootMainJsKey
]
=
mainJsPath
;
process
.
UNI_ENTRY
[
pkgRootMainJsKey
]
=
mainJsPath
}
})
;
})
}
process
.
UNI_SUB_PACKAGES_ROOT
=
{}
process
.
UNI_NVUE_ENTRY
=
{}
...
...
packages/uni-mp-weixin/lib/createIndependentPlugin.js
浏览文件 @
ef4f0fc4
const
AddShareAbilityToRuntimePlugin
=
require
(
'
./independent-plugins/add-share-ability-to-runtime-plugin
'
)
;
const
GenerateIndepndentEntryPlugin
=
require
(
'
./independent-plugins/generate-indepndent-entry-plugin
'
)
;
const
InjectEntryJsToIndependentPlugin
=
require
(
'
./independent-plugins/inject-entry-to-independent-plugin
'
)
;
const
InjectMainCssToIndependentCssPlugin
=
require
(
'
./independent-plugins/inject-main-css-to-independent-plugin
'
)
;
const
RunDefaultAppPlugin
=
require
(
'
./independent-plugins/run-default-app-plugin
'
)
;
const
SplitIndependentChunksPlugin
=
require
(
'
./independent-plugins/split-independent-chunks-plugin
'
)
;
const
ModifyUniAppWebpackConfigPlugin
=
require
(
'
./independent-plugins/modify-uniapp-webpack-config-Plugin
'
)
;
const
AddWxMpRuntimePlugin
=
require
(
'
./independent-plugins/add-weixin-mp-runtime-plugin
'
)
;
const
AppInterceptorPlugin
=
require
(
'
./independent-plugins/app-interceptor-plugin
'
)
;
const
AddShareAbilityToRuntimePlugin
=
require
(
'
./independent-plugins/add-share-ability-to-runtime-plugin
'
)
const
GenerateIndepndentEntryPlugin
=
require
(
'
./independent-plugins/generate-indepndent-entry-plugin
'
)
const
InjectEntryJsToIndependentPlugin
=
require
(
'
./independent-plugins/inject-entry-to-independent-plugin
'
)
const
InjectMainCssToIndependentCssPlugin
=
require
(
'
./independent-plugins/inject-main-css-to-independent-plugin
'
)
const
RunDefaultAppPlugin
=
require
(
'
./independent-plugins/run-default-app-plugin
'
)
const
SplitIndependentChunksPlugin
=
require
(
'
./independent-plugins/split-independent-chunks-plugin
'
)
const
ModifyUniAppWebpackConfigPlugin
=
require
(
'
./independent-plugins/modify-uniapp-webpack-config-Plugin
'
)
const
AddWxMpRuntimePlugin
=
require
(
'
./independent-plugins/add-weixin-mp-runtime-plugin
'
)
const
AppInterceptorPlugin
=
require
(
'
./independent-plugins/app-interceptor-plugin
'
)
module
.
exports
=
function
createIndependentPlugins
()
{
const
manifestConfig
=
process
.
UNI_MANIFEST
;
const
weixinConfig
=
manifestConfig
[
'
mp-weixin
'
];
const
independentSwitch
=
!!
weixinConfig
.
independent
;
if
(
!
independentSwitch
)
return
[];
const
manifestConfig
=
process
.
UNI_MANIFEST
const
weixinConfig
=
manifestConfig
[
'
mp-weixin
'
]
const
independentSwitch
=
!!
weixinConfig
.
independent
if
(
!
independentSwitch
)
return
[]
// 支持构造微信小程序的独立分包
const
independentPlugins
=
[
new
SplitIndependentChunksPlugin
(),
new
ModifyUniAppWebpackConfigPlugin
(),
// 修改 webpack配置
new
AddShareAbilityToRuntimePlugin
(),
// 保证独立分包和主包使用的相同的runtime.js
new
GenerateIndepndentEntryPlugin
(),
// 生成独立分包执行入口文件(代替app.js
new
InjectEntryJsToIndependentPlugin
(),
// 为独立分包注入执行入口
new
RunDefaultAppPlugin
(),
// 确保app.js中的App()被执行一次
// 独立分包中 App,getApp 调用拦截
new
AddWxMpRuntimePlugin
(),
new
AppInterceptorPlugin
()
];
// 支持构造微信小程序的独立分包
const
independentPlugins
=
[
new
SplitIndependentChunksPlugin
(),
new
ModifyUniAppWebpackConfigPlugin
(),
// 修改 webpack配置
new
AddShareAbilityToRuntimePlugin
(),
// 保证独立分包和主包使用的相同的runtime.js
new
GenerateIndepndentEntryPlugin
(),
// 生成独立分包执行入口文件(代替app.js
new
InjectEntryJsToIndependentPlugin
(),
// 为独立分包注入执行入口
new
RunDefaultAppPlugin
(),
// 确保app.js中的App()被执行一次
// 独立分包中 App,getApp 调用拦截
new
AddWxMpRuntimePlugin
(),
new
AppInterceptorPlugin
()
]
const
insertAppCssToIndependentSwitch
=
!!
weixinConfig
.
insertAppCssToIndependent
;
if
(
insertAppCssToIndependentSwitch
)
{
// 需要在 cacheSet 后面
independentPlugins
.
push
(
new
InjectMainCssToIndependentCssPlugin
());
// 目前只对页面注入了,组件未注入
}
const
insertAppCssToIndependentSwitch
=
!!
weixinConfig
.
insertAppCssToIndependent
if
(
insertAppCssToIndependentSwitch
)
{
// 需要在 cacheSet 后面
independentPlugins
.
push
(
new
InjectMainCssToIndependentCssPlugin
())
// 目前只对页面注入了,组件未注入
}
return
independentPlugins
;
};
\ No newline at end of file
return
independentPlugins
}
packages/uni-mp-weixin/lib/uni.config.js
浏览文件 @
ef4f0fc4
...
...
@@ -42,18 +42,18 @@ module.exports = {
const
workers
=
platformOptions
.
workers
workers
&&
copyOptions
.
push
(
workers
)
const
manifestConfig
=
process
.
UNI_MANIFEST
;
const
weixinConfig
=
manifestConfig
[
'
mp-weixin
'
]
||
{}
;
const
copyWxComponentsOnDemandSwitch
=
!!
weixinConfig
.
copyWxComponentsOnDemand
;
// 默认值false
const
manifestConfig
=
process
.
UNI_MANIFEST
const
weixinConfig
=
manifestConfig
[
'
mp-weixin
'
]
||
{}
const
copyWxComponentsOnDemandSwitch
=
!!
weixinConfig
.
copyWxComponentsOnDemand
// 默认值false
if
(
!
copyWxComponentsOnDemandSwitch
)
{
const
wxcomponentsDir
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
COMPONENTS_DIR_NAME
)
;
const
wxcomponentsDir
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
COMPONENTS_DIR_NAME
)
if
(
fs
.
existsSync
(
wxcomponentsDir
))
{
copyOptions
.
push
({
from
:
wxcomponentsDir
,
to
:
COMPONENTS_DIR_NAME
,
ignore
:
[
'
**/*.vue
'
,
'
**/*.css
'
]
// v3 会自动转换生成vue,css文件,需要过滤
})
;
})
}
}
global
.
uniModules
.
forEach
(
module
=>
{
...
...
packages/vue-cli-plugin-uni/lib/mp/index.js
浏览文件 @
ef4f0fc4
...
...
@@ -23,7 +23,7 @@ function createUniMPPlugin () {
return
new
WebpackUniMPPlugin
()
}
const
createWxMpIndependentPlugins
=
require
(
'
@dcloudio/uni-mp-weixin/lib/createIndependentPlugin
'
)
;
const
createWxMpIndependentPlugins
=
require
(
'
@dcloudio/uni-mp-weixin/lib/createIndependentPlugin
'
)
function
getProvides
()
{
const
uniPath
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
).
getMPRuntimePath
()
...
...
packages/vue-cli-plugin-uni/lib/split-chunks.js
浏览文件 @
ef4f0fc4
...
...
@@ -4,12 +4,12 @@ const {
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
subPkgsInfo
=
Object
.
values
(
process
.
UNI_SUBPACKAGES
)
;
const
normalFilter
=
({
independent
})
=>
!
independent
;
const
independentFilter
=
({
independent
})
=>
independent
;
const
map2Root
=
({
root
})
=>
root
+
'
/
'
;
const
normalSubPackageRoots
=
subPkgsInfo
.
filter
(
normalFilter
).
map
(
map2Root
)
;
const
independentSubpackageRoots
=
subPkgsInfo
.
filter
(
independentFilter
).
map
(
map2Root
)
;
const
subPkgsInfo
=
Object
.
values
(
process
.
UNI_SUBPACKAGES
)
const
normalFilter
=
({
independent
})
=>
!
independent
const
independentFilter
=
({
independent
})
=>
independent
const
map2Root
=
({
root
})
=>
root
+
'
/
'
const
normalSubPackageRoots
=
subPkgsInfo
.
filter
(
normalFilter
).
map
(
map2Root
)
const
independentSubpackageRoots
=
subPkgsInfo
.
filter
(
independentFilter
).
map
(
map2Root
)
function
createCacheGroups
()
{
const
cacheGroups
=
{}
...
...
@@ -187,9 +187,9 @@ module.exports = function getSplitChunks () {
}
// 独立分包除外
const
independentRoot
=
independentSubpackageRoots
.
find
(
root
=>
resource
.
indexOf
(
root
)
>=
0
)
;
const
independentRoot
=
independentSubpackageRoots
.
find
(
root
=>
resource
.
indexOf
(
root
)
>=
0
)
if
(
!
independentRoot
)
{
return
true
;
return
true
}
}
}
else
{
...
...
packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
浏览文件 @
ef4f0fc4
...
...
@@ -105,11 +105,11 @@ module.exports = function generateComponent (compilation, jsonpFunction = 'webpa
}
const
origSource
=
assets
[
name
].
source
()
if
(
isVueComponent
)
{
componentChunkNameMap
[
name
]
=
moduleId
}
else
if
(
isVueOuterComponent
)
{
const
startIndex
=
name
.
indexOf
(
vueOuterComponentSting
)
+
vueOuterComponentSting
.
length
+
1
;
const
startIndex
=
name
.
indexOf
(
vueOuterComponentSting
)
+
vueOuterComponentSting
.
length
+
1
const
rightOriginalComponentName
=
name
.
substring
(
startIndex
)
moduleId
=
componentChunkNameMap
[
rightOriginalComponentName
]
}
...
...
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
浏览文件 @
ef4f0fc4
...
...
@@ -26,7 +26,7 @@ const mpBaiduDynamicLibs = [
'
dynamicLib://myDynamicLib/vrvideo
'
]
const
AnalyzeDependency
=
require
(
'
@dcloudio/uni-mp-weixin/lib/independent-plugins/optimize-components-position/index
'
)
;
const
AnalyzeDependency
=
require
(
'
@dcloudio/uni-mp-weixin/lib/independent-plugins/optimize-components-position/index
'
)
function
analyzeUsingComponents
()
{
if
(
!
process
.
env
.
UNI_OPT_SUBPACKAGES
)
{
...
...
@@ -112,11 +112,11 @@ function normalizeUsingComponents (file, usingComponents) {
return
usingComponents
}
const
cacheFileMap
=
new
Map
()
;
const
cacheFileMap
=
new
Map
()
module
.
exports
=
function
generateJson
(
compilation
)
{
analyzeUsingComponents
()
const
emitFileMap
=
new
Map
([...
cacheFileMap
])
;
const
emitFileMap
=
new
Map
([...
cacheFileMap
])
const
jsonFileMap
=
getChangedJsonFileMap
()
for
(
const
name
of
jsonFileMap
.
keys
())
{
const
jsonObj
=
JSON
.
parse
(
jsonFileMap
.
get
(
name
))
...
...
@@ -214,24 +214,23 @@ module.exports = function generateJson (compilation) {
jsonObj
.
usingComponents
=
normalizeUsingComponents
(
name
,
jsonObj
.
usingComponents
)
}
emitFileMap
.
set
(
name
,
jsonObj
)
;
cacheFileMap
.
set
(
name
,
JSON
.
parse
(
JSON
.
stringify
(
jsonObj
)))
;
// 做一次拷贝,emitFileMap中内容在后面会被修改
emitFileMap
.
set
(
name
,
jsonObj
)
cacheFileMap
.
set
(
name
,
JSON
.
parse
(
JSON
.
stringify
(
jsonObj
)))
// 做一次拷贝,emitFileMap中内容在后面会被修改
}
// 组件依赖分析
(
new
AnalyzeDependency
()).
init
(
emitFileMap
,
compilation
);
for
(
const
[
name
,
jsonObj
]
of
emitFileMap
)
{
if
(
name
===
'
app.json
'
)
{
// 删除manifest.json携带的配置项
delete
jsonObj
.
insertAppCssToIndependent
;
delete
jsonObj
.
independent
;
delete
jsonObj
.
copyWxComponentsOnDemand
;
}
else
{
// 删除用于临时记录的属性
delete
jsonObj
.
usingGlobalComponents
;
}
emit
(
name
,
jsonObj
,
compilation
);
(
new
AnalyzeDependency
()).
init
(
emitFileMap
,
compilation
)
for
(
const
[
name
,
jsonObj
]
of
emitFileMap
)
{
if
(
name
===
'
app.json
'
)
{
// 删除manifest.json携带的配置项
delete
jsonObj
.
insertAppCssToIndependent
delete
jsonObj
.
independent
delete
jsonObj
.
copyWxComponentsOnDemand
}
else
{
// 删除用于临时记录的属性
delete
jsonObj
.
usingGlobalComponents
}
emit
(
name
,
jsonObj
,
compilation
)
}
if
(
process
.
env
.
UNI_USING_CACHE
&&
jsonFileMap
.
size
)
{
setTimeout
(()
=>
{
...
...
@@ -242,42 +241,41 @@ module.exports = function generateJson (compilation) {
function
emit
(
name
,
jsonObj
,
compilation
)
{
if
(
jsonObj
.
usingComponents
)
{
jsonObj
.
usingComponents
=
Object
.
assign
({},
jsonObj
.
usingComponents
)
;
jsonObj
.
usingComponents
=
Object
.
assign
({},
jsonObj
.
usingComponents
)
}
const
source
=
JSON
.
stringify
(
jsonObj
,
null
,
2
)
const
jsFile
=
name
.
replace
(
'
.json
'
,
'
.js
'
)
if
(
!
[
'
app.js
'
,
'
manifest.js
'
,
'
mini.project.js
'
,
'
quickapp.config.js
'
,
'
project.config.js
'
,
'
project.swan.js
'
].
includes
(
jsFile
)
&&
const
jsFile
=
name
.
replace
(
'
.json
'
,
'
.js
'
)
if
(
!
[
'
app.js
'
,
'
manifest.js
'
,
'
mini.project.js
'
,
'
quickapp.config.js
'
,
'
project.config.js
'
,
'
project.swan.js
'
].
includes
(
jsFile
)
&&
!
compilation
.
assets
[
jsFile
]
)
{
const
jsFileAsset
=
{
size
()
{
return
Buffer
.
byteLength
(
EMPTY_COMPONENT
,
'
utf8
'
)
},
source
()
{
return
EMPTY_COMPONENT
}
}
compilation
.
assets
[
jsFile
]
=
jsFileAsset
}
const
jsonAsset
=
{
)
{
const
jsFileAsset
=
{
size
()
{
return
Buffer
.
byteLength
(
source
,
'
utf8
'
)
return
Buffer
.
byteLength
(
EMPTY_COMPONENT
,
'
utf8
'
)
},
source
()
{
return
source
return
EMPTY_COMPONENT
}
}
compilation
.
assets
[
jsFile
]
=
jsFileAsset
}
const
jsonAsset
=
{
size
()
{
return
Buffer
.
byteLength
(
source
,
'
utf8
'
)
},
source
()
{
return
source
}
}
compilation
.
assets
[
name
]
=
jsonAsset
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录