Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ripplebb
uni-app
提交
aecbbd7c
U
uni-app
项目概览
ripplebb
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aecbbd7c
编写于
6月 10, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(plugin): support custom component
上级
5b11af73
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
96 addition
and
30 deletion
+96
-30
build/build.plugin.js
build/build.plugin.js
+16
-6
lib/extends-api-loader/index.js
lib/extends-api-loader/index.js
+0
-0
lib/extends-component-loader/index.js
lib/extends-component-loader/index.js
+58
-0
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+6
-8
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/vue-cli-plugin-uni/lib/split-chunks.js
packages/vue-cli-plugin-uni/lib/split-chunks.js
+15
-15
未找到文件。
build/build.plugin.js
浏览文件 @
aecbbd7c
...
...
@@ -23,11 +23,11 @@ let pluginDir = process.argv[2]
if
(
!
pluginDir
)
{
console
.
error
(
'
缺少参数
'
)
process
.
exit
(
0
)
}
if
(
pluginDir
.
indexOf
(
'
/
'
)
===
-
1
)
{
pluginDir
=
path
.
resolve
(
__dirname
,
'
../packages/uni-
'
+
pluginDir
)
}
}
if
(
pluginDir
.
indexOf
(
'
/
'
)
===
-
1
)
{
pluginDir
=
path
.
resolve
(
__dirname
,
'
../packages/uni-
'
+
pluginDir
)
}
const
pkg
=
require
(
path
.
join
(
pluginDir
,
'
package.json
'
))
if
(
!
pkg
[
'
uni-app
'
])
{
...
...
@@ -47,9 +47,19 @@ service.webpackRawConfigFns.push(function () {
},
module
:
{
rules
:
[{
test
:
path
.
resolve
(
__dirname
,
'
../src/core/view/components/index.js
'
),
use
:
[{
loader
:
path
.
resolve
(
__dirname
,
'
../lib/extends-component-loader
'
),
options
:
{
extends
:
path
.
resolve
(
pluginDir
,
'
src/view/components
'
),
base
:
path
.
resolve
(
__dirname
,
'
../src/core/view/components
'
),
platform
:
path
.
resolve
(
__dirname
,
'
../src/platforms/h5/view/components
'
)
}
}]
},
{
test
:
path
.
resolve
(
__dirname
,
'
../src/platforms/h5/service/api/index.js
'
),
use
:
[{
loader
:
path
.
resolve
(
__dirname
,
'
../lib/extends-loader
'
),
loader
:
path
.
resolve
(
__dirname
,
'
../lib/extends-
api-
loader
'
),
options
:
{
extends
:
path
.
resolve
(
pluginDir
,
'
src/service/api
'
),
base
:
path
.
resolve
(
__dirname
,
'
../src/platforms/h5/service/api
'
)
...
...
lib/extends-loader/index.js
→
lib/extends-
api-
loader/index.js
浏览文件 @
aecbbd7c
文件已移动
lib/extends-component-loader/index.js
0 → 100644
浏览文件 @
aecbbd7c
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
glob
=
require
(
'
glob
'
)
const
loaderUtils
=
require
(
'
loader-utils
'
)
const
isWin
=
/^win/
.
test
(
process
.
platform
)
const
normalizePath
=
path
=>
(
isWin
?
path
.
replace
(
/
\\
/g
,
'
/
'
)
:
path
)
module
.
exports
=
function
loader
(
source
)
{
const
options
=
loaderUtils
.
getOptions
(
this
)
const
baseDir
=
options
[
'
base
'
]
const
platformDir
=
options
[
'
platform
'
]
const
extendsDir
=
options
[
'
extends
'
]
const
components
=
[]
const
extendsFiles
=
[]
// extends目录均导出
glob
.
sync
(
'
**/index.vue
'
,
{
cwd
:
extendsDir
}).
forEach
(
file
=>
{
extendsFiles
.
push
(
file
)
components
.
push
(
normalizePath
(
path
.
join
(
extendsDir
,
file
)))
})
//base目录中有,extends无的导出
glob
.
sync
(
'
**/index.vue
'
,
{
cwd
:
baseDir
}).
forEach
(
file
=>
{
if
(
!
extendsFiles
.
includes
(
file
))
{
components
.
push
(
normalizePath
(
path
.
join
(
baseDir
,
file
)))
}
})
//platform目录中有,extends无的导出
glob
.
sync
(
'
**/index.vue
'
,
{
cwd
:
platformDir
}).
forEach
(
file
=>
{
if
(
!
extendsFiles
.
includes
(
file
))
{
components
.
push
(
normalizePath
(
path
.
join
(
platformDir
,
file
)))
}
})
const
componentsCode
=
components
.
map
(
component
=>
{
return
`require('
${
component
}
').default`
}).
join
(
'
,
'
)
return
`
import Vue from 'vue'
import baseMixin from 'uni-mixins/base'
import animation from 'uni-mixins/animation'
[
${
componentsCode
}
].forEach(component=>{
component.mixins = component.mixins ? [].concat(baseMixin, component.mixins) : [baseMixin]
component.mixins.push(animation)
component.name = 'VUni' + component.name
component.isReserved = true
Vue.component(component.name, component)
})
`
}
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
aecbbd7c
...
...
@@ -7526,9 +7526,8 @@ var serviceContext = (function () {
const
SUB_FILENAME
=
'
app-sub-service.js
'
;
function
evaluateScriptFile
(
file
,
callback
)
{
setTimeout
(()
=>
{
callback
();
},
2000
);
// TODO 有可能当前 instance 是非 app-service
weex
.
requireModule
(
'
plus
'
).
evalJSFiles
([
file
],
callback
);
}
function
loadSubPackage$1
({
...
...
@@ -8496,9 +8495,8 @@ var serviceContext = (function () {
const
SUB_FILENAME$1
=
'
app-sub-service.js
'
;
function
evaluateScriptFiles
(
files
,
callback
)
{
setTimeout
(()
=>
{
callback
();
},
2000
);
// TODO 有可能当前 instance 是非 app-service
weex
.
requireModule
(
'
plus
'
).
evalJSFiles
(
files
,
callback
);
}
function
loadSubPackages
(
packages
,
callback
)
{
...
...
@@ -8606,7 +8604,7 @@ var serviceContext = (function () {
openType
===
'
reLaunch
'
||
(
!
__uniConfig
.
realEntryPagePath
&&
pages
.
length
===
0
getCurrentPages$1
().
length
===
0
// redirectTo
)
)
{
routeOptions
.
meta
.
isQuit
=
true
;
...
...
@@ -13386,7 +13384,7 @@ var serviceContext = (function () {
if
(
~
conflictTags
.
indexOf
(
tag
))
{
// svg 部分标签名称与 uni 标签冲突
return
false
}
return
oldGetTagNamespace
(
tag
)
||
false
return
oldGetTagNamespace
(
tag
)
};
}
...
...
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
aecbbd7c
此差异已折叠。
点击以展开。
packages/vue-cli-plugin-uni/lib/split-chunks.js
浏览文件 @
aecbbd7c
...
...
@@ -4,12 +4,12 @@ const {
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
function
createCacheGroups
()
{
function
createCacheGroups
()
{
const
cacheGroups
=
{}
if
(
process
.
UNI_CONFUSION
)
{
// 加密
cacheGroups
.
confusion
=
{
enforce
:
true
,
test
:
function
(
module
)
{
test
:
function
(
module
)
{
if
(
!
module
.
resource
)
{
return
false
}
...
...
@@ -26,7 +26,7 @@ function createCacheGroups() {
process
.
env
.
UNI_OPT_SUBPACKAGES
&&
Object
.
keys
(
process
.
UNI_SUBPACKAGES
).
forEach
(
root
=>
{
cacheGroups
[
root
]
=
{
enforce
:
true
,
test
:
function
(
module
)
{
test
:
function
(
module
)
{
if
(
!
module
.
resource
)
{
return
false
}
...
...
@@ -42,7 +42,7 @@ function createCacheGroups() {
return
cacheGroups
}
module
.
exports
=
function
getSplitChunks
()
{
module
.
exports
=
function
getSplitChunks
()
{
const
{
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
...
...
@@ -69,22 +69,22 @@ module.exports = function getSplitChunks() {
if
(
!
process
.
env
.
UNI_OPT_SUBPACKAGES
)
{
return
{
chunks
(
chunk
)
{
// 防止 node_modules 内 vue 组件被 split
chunks
(
chunk
)
{
// 防止 node_modules 内 vue 组件被 split
return
chunk
.
name
.
indexOf
(
'
node-modules
'
)
!==
0
},
cacheGroups
:
{
default
:
false
,
vendors
:
false
,
commons
:
{
test
(
module
)
{
test
(
module
)
{
if
(
module
.
type
===
'
css/mini-extract
'
)
{
return
false
}
if
(
module
.
resource
&&
(
module
.
resource
.
indexOf
(
'
.vue
'
)
!==
-
1
||
module
.
resource
.
indexOf
(
'
.vue
'
)
!==
-
1
||
module
.
resource
.
indexOf
(
'
.nvue
'
)
!==
-
1
||
normalizePath
(
module
.
resource
).
indexOf
(
mainPath
)
===
0
// main.js
))
{
))
{
return
false
}
return
true
...
...
@@ -97,7 +97,7 @@ module.exports = function getSplitChunks() {
}
}
function
baseTest
(
module
)
{
function
baseTest
(
module
)
{
if
(
module
.
type
===
'
css/mini-extract
'
)
{
return
false
}
...
...
@@ -119,7 +119,7 @@ module.exports = function getSplitChunks() {
default
:
false
,
vendors
:
false
,
commons
:
{
test
(
module
,
chunks
)
{
test
(
module
,
chunks
)
{
if
(
!
baseTest
(
module
))
{
return
false
}
...
...
@@ -144,7 +144,7 @@ module.exports = function getSplitChunks() {
}
}
const
findSubPackages
=
function
(
chunks
)
{
const
findSubPackages
=
function
(
chunks
)
{
return
chunks
.
reduce
((
pkgs
,
item
)
=>
{
const
name
=
normalizePath
(
item
.
name
)
const
pkgRoot
=
subPackageRoots
.
find
(
root
=>
name
.
indexOf
(
root
)
===
0
)
...
...
@@ -153,16 +153,16 @@ module.exports = function getSplitChunks() {
},
new
Set
())
}
const
hasMainPackage
=
function
(
chunks
)
{
const
hasMainPackage
=
function
(
chunks
)
{
return
chunks
.
find
(
item
=>
!
subPackageRoots
.
find
(
root
=>
item
.
name
.
indexOf
(
root
)
===
0
))
}
const
subPackageRoots
=
Object
.
keys
(
process
.
UNI_SUBPACKAGES
).
map
(
root
=>
root
+
'
/
'
)
Object
.
keys
(
process
.
UNI_SUBPACKAGES
).
forEach
(
root
=>
{
(
function
(
root
)
{
(
function
(
root
)
{
cacheGroups
[
root
+
'
/commons
'
]
=
{
test
(
module
,
chunks
)
{
test
(
module
,
chunks
)
{
if
(
!
baseTest
(
module
))
{
return
false
}
...
...
@@ -187,7 +187,7 @@ module.exports = function getSplitChunks() {
})
return
{
chunks
(
chunk
)
{
// 防止 node_modules 内 vue 组件被 split
chunks
(
chunk
)
{
// 防止 node_modules 内 vue 组件被 split
return
chunk
.
name
.
indexOf
(
'
node-modules
'
)
!==
0
},
cacheGroups
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录