Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
4d1a059e
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
720
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4d1a059e
编写于
3月 31, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
4a650a5b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
43 addition
and
8 deletion
+43
-8
packages/uni-cli-shared/lib/uni_modules/uni_modules.js
packages/uni-cli-shared/lib/uni_modules/uni_modules.js
+43
-8
未找到文件。
packages/uni-cli-shared/lib/uni_modules/uni_modules.js
浏览文件 @
4d1a059e
...
...
@@ -12,9 +12,15 @@ function parseUniExtApis(vite = true) {
if
(
!
fs_extra_1
.
default
.
existsSync
(
uniModulesDir
))
{
return
{};
}
let
platform
=
process
.
env
.
UNI_PLATFORM
;
if
(
platform
===
'
h5
'
)
{
platform
=
'
web
'
;
}
else
if
(
platform
===
'
app-plus
'
)
{
platform
=
'
app
'
;
}
const
injects
=
{};
fs_extra_1
.
default
.
readdirSync
(
uniModulesDir
).
forEach
((
uniModuleDir
)
=>
{
var
_a
,
_b
;
// 必须以 uni- 开头
if
(
!
uniModuleDir
.
startsWith
(
'
uni-
'
))
{
return
;
...
...
@@ -24,13 +30,25 @@ function parseUniExtApis(vite = true) {
return
;
}
try
{
const
exports
=
(
_b
=
(
_a
=
JSON
.
parse
(
fs_extra_1
.
default
.
readFileSync
(
pkgPath
,
'
utf8
'
)))
===
null
||
_a
===
void
0
?
void
0
:
_a
.
uni_modules
)
===
null
||
_b
===
void
0
?
void
0
:
_b
[
'
uni-ext-api
'
];
const
exports
=
JSON
.
parse
(
fs_extra_1
.
default
.
readFileSync
(
pkgPath
,
'
utf8
'
))
?.
uni_modules
?.[
'
uni-ext-api
'
];
if
(
exports
)
{
Object
.
assign
(
injects
,
parseInjects
(
vite
,
process
.
env
.
UNI_PLATFORM
===
'
h5
'
?
'
web
'
:
process
.
env
.
UNI_PLATFORM
,
`@/uni_modules/
${
uniModuleDir
}
`
,
exports
));
const
curInjects
=
parseInjects
(
vite
,
platform
,
`@/uni_modules/
${
uniModuleDir
}
`
,
exports
);
if
(
platform
===
'
app
'
)
{
Object
.
keys
(
curInjects
).
forEach
((
name
)
=>
{
const
options
=
curInjects
[
name
];
// js 平台禁用了
if
(
Array
.
isArray
(
options
)
&&
options
.
length
===
3
)
{
if
(
options
[
2
]
&&
options
[
2
].
js
===
false
)
{
delete
curInjects
[
name
];
}
}
});
}
Object
.
assign
(
injects
,
curInjects
);
}
catch
(
e
)
{
}
catch
(
e
)
{
}
});
return
injects
;
}
...
...
@@ -73,12 +91,12 @@ function parseInjects(vite = true, platform, source, exports = {}) {
}
const
injects
=
{};
for
(
const
key
in
rootDefines
)
{
Object
.
assign
(
injects
,
parseInject
(
vite
,
source
,
'
uni
'
,
rootDefines
[
key
]));
Object
.
assign
(
injects
,
parseInject
(
vite
,
platform
,
source
,
'
uni
'
,
rootDefines
[
key
]));
}
return
injects
;
}
exports
.
parseInjects
=
parseInjects
;
function
parseInject
(
vite
=
true
,
source
,
globalObject
,
define
)
{
function
parseInject
(
vite
=
true
,
platform
,
source
,
globalObject
,
define
)
{
const
injects
=
{};
if
(
define
===
false
)
{
}
...
...
@@ -95,7 +113,24 @@ function parseInject(vite = true, source, globalObject, define) {
else
{
const
keys
=
Object
.
keys
(
define
);
keys
.
forEach
((
d
)
=>
{
if
(
typeof
define
[
d
]
===
'
string
'
)
{
injects
[
globalObject
+
'
.
'
+
d
]
=
[
source
,
define
[
d
]];
}
else
{
const
defineOptions
=
define
[
d
];
if
(
defineOptions
[
platform
]
!==
false
)
{
if
(
platform
===
'
app
'
)
{
injects
[
globalObject
+
'
.
'
+
d
]
=
[
source
,
defineOptions
.
name
||
d
,
defineOptions
.
app
,
];
}
else
{
injects
[
globalObject
+
'
.
'
+
d
]
=
[
source
,
defineOptions
.
name
||
d
];
}
}
}
});
}
return
injects
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录