Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
1d3d8dcd
U
uni-app
项目概览
小浣熊撸代码
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
1d3d8dcd
编写于
11月 01, 2021
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: enable multi-process compile
上级
d3637999
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
81 addition
and
24 deletion
+81
-24
scripts/build.js
scripts/build.js
+60
-4
scripts/utils.js
scripts/utils.js
+21
-20
未找到文件。
scripts/build.js
浏览文件 @
1d3d8dcd
...
...
@@ -2,16 +2,18 @@ const fs = require('fs-extra')
const
path
=
require
(
'
path
'
)
const
chalk
=
require
(
'
chalk
'
)
const
execa
=
require
(
'
execa
'
)
const
{
spawn
}
=
require
(
'
child_process
'
)
const
{
extract
}
=
require
(
'
./apiExtractor
'
)
const
{
targets
:
allTargets
,
fuzzyMatchTarget
}
=
require
(
'
./utils
'
)
const
{
targets
:
allTargets
,
fuzzyMatchTarget
,
priority
}
=
require
(
'
./utils
'
)
const
args
=
require
(
'
minimist
'
)(
process
.
argv
.
slice
(
2
))
const
targets
=
args
.
_
// const formats = args.formats || args.f
const
devOnly
=
args
.
devOnly
||
args
.
d
const
isRelease
=
args
.
release
const
multiProcess
=
args
.
m
// const buildTypes = args.t || args.types || isRelease
const
buildAllMatching
=
args
.
all
||
args
.
a
...
...
@@ -25,14 +27,68 @@ async function run() {
}
}
function
buildWithChildProcess
(
target
)
{
const
args
=
[
__filename
,
target
]
devOnly
&&
args
.
push
(
'
-d
'
)
isRelease
&&
args
.
push
(
'
--release
'
)
const
child
=
spawn
(
'
node
'
,
args
,
{
cwd
:
process
.
cwd
(),
stdio
:
'
inherit
'
,
})
return
new
Promise
((
resolve
,
reject
)
=>
{
child
.
on
(
'
exit
'
,
()
=>
{
const
exitCode
=
child
.
exitCode
if
(
exitCode
===
0
)
{
resolve
()
}
else
{
reject
(
new
Error
(
`build
${
target
}
failed with error code
${
exitCode
}
`
))
}
})
})
}
function
getTargetGroup
(
targets
)
{
const
group
=
{}
for
(
let
i
=
0
;
i
<
targets
.
length
;
i
++
)
{
const
target
=
targets
[
i
]
const
targetPriority
=
priority
[
target
]
if
(
!
group
[
targetPriority
])
{
group
[
targetPriority
]
=
[
target
]
}
else
{
group
[
targetPriority
].
push
(
target
)
}
}
return
group
}
async
function
buildAll
(
targets
)
{
for
(
const
target
of
targets
)
{
console
.
log
(
`\n
${
chalk
.
blueBright
(
chalk
.
bold
(
target
))}
:`
)
await
build
(
target
)
if
(
!
multiProcess
)
{
for
(
const
target
of
targets
)
{
await
build
(
target
)
}
return
}
if
(
targets
.
length
===
1
)
{
// child process or single target
await
build
(
targets
[
0
])
return
}
console
.
warn
(
'
compiling with multi process
'
)
const
group
=
getTargetGroup
(
targets
)
const
keys
=
Object
.
keys
(
group
).
sort
((
a
,
b
)
=>
{
return
b
-
a
})
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
const
key
=
keys
[
i
]
const
groupTargets
=
group
[
key
]
await
Promise
.
all
(
groupTargets
.
map
((
target
)
=>
buildWithChildProcess
(
target
))
)
}
}
async
function
build
(
target
)
{
console
.
log
(
`\n
${
chalk
.
blueBright
(
chalk
.
bold
(
target
))}
:`
)
const
pkgDir
=
path
.
resolve
(
`packages/
${
target
}
`
)
const
pkg
=
require
(
`
${
pkgDir
}
/package.json`
)
...
...
scripts/utils.js
浏览文件 @
1d3d8dcd
...
...
@@ -7,28 +7,29 @@ const priority = {
'
uni-app
'
:
90
,
'
uni-stat
'
:
90
,
'
uni-i18n
'
:
90
,
'
uni-mp-vue
'
:
80
,
'
uni-mp-alipay
'
:
70
,
'
uni-mp-baidu
'
:
70
,
'
uni-mp-kuaishou
'
:
70
,
'
uni-mp-qq
'
:
70
,
'
uni-mp-toutiao
'
:
70
,
'
uni-mp-vue
'
:
90
,
'
uni-cli-shared
'
:
80
,
'
uni-h5
'
:
75
,
'
uni-mp-vite
'
:
75
,
'
uni-mp-weixin
'
:
70
,
'
uni-quickapp-webview
'
:
70
,
'
uni-cli-shared
'
:
60
,
'
uni-cli-nvue
'
:
55
,
'
uni-h5
'
:
50
,
'
uni-h5-vite
'
:
40
,
'
uni-app-vue
'
:
35
,
'
uni-app-plus
'
:
30
,
'
uni-app-vite
'
:
30
,
'
uni-mp-vite
'
:
30
,
'
uni-mp-compiler
'
:
30
,
'
vite-plugin-uni
'
:
20
,
'
uni-cloud
'
:
10
,
'
uni-automator
'
:
10
,
'
size-check
'
:
1
,
'
uni-cli-nvue
'
:
70
,
'
uni-mp-compiler
'
:
70
,
'
uni-mp-alipay
'
:
60
,
'
uni-mp-baidu
'
:
60
,
'
uni-mp-kuaishou
'
:
60
,
'
uni-mp-qq
'
:
60
,
'
uni-mp-toutiao
'
:
60
,
'
uni-quickapp-webview
'
:
60
,
'
uni-h5-vite
'
:
70
,
'
uni-app-vue
'
:
70
,
'
uni-app-plus
'
:
70
,
'
uni-app-vite
'
:
70
,
'
vite-plugin-uni
'
:
70
,
'
uni-cloud
'
:
70
,
'
uni-automator
'
:
70
,
'
size-check
'
:
60
,
}
exports
.
priority
=
priority
const
targets
=
(
exports
.
targets
=
fs
.
readdirSync
(
'
packages
'
).
filter
((
f
)
=>
{
if
(
!
fs
.
statSync
(
`packages/
${
f
}
`
).
isDirectory
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录