Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
uni-app
提交
8bb51b7e
U
uni-app
项目概览
Metz
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
8bb51b7e
编写于
10月 14, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: uni_modules
上级
23194972
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
87 addition
and
80 deletion
+87
-80
packages/uni-cli-shared/lib/uni_modules/uni_modules.js
packages/uni-cli-shared/lib/uni_modules/uni_modules.js
+87
-80
未找到文件。
packages/uni-cli-shared/lib/uni_modules/uni_modules.js
浏览文件 @
8bb51b7e
'
use strict
'
"
use strict
"
;
var
__importDefault
=
(
this
&&
this
.
__importDefault
)
||
function
(
mod
)
{
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
default
:
mod
}
}
Object
.
defineProperty
(
exports
,
'
__esModule
'
,
{
value
:
true
})
exports
.
parseDefines
=
exports
.
parseExports
=
exports
.
genUniModulesExports
=
void
0
const
path_1
=
__importDefault
(
require
(
'
path
'
))
const
fs_extra_1
=
__importDefault
(
require
(
'
fs-extra
'
))
const
merge_1
=
require
(
'
merge
'
)
function
genUniModulesExports
()
{
const
uniModulesDir
=
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
)
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
}
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
parseDefines
=
exports
.
parseExports
=
exports
.
genUniModulesExports
=
void
0
;
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
fs_extra_1
=
__importDefault
(
require
(
"
fs-extra
"
));
const
merge_1
=
require
(
"
merge
"
);
function
genUniModulesExports
()
{
const
uniModulesDir
=
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
);
if
(
!
fs_extra_1
.
default
.
existsSync
(
uniModulesDir
))
{
return
''
return
''
;
}
const
importCodes
=
[]
const
assignCodes
=
[]
const
importCodes
=
[];
const
assignCodes
=
[];
fs_extra_1
.
default
.
readdirSync
(
uniModulesDir
).
forEach
((
uniModuleDir
)
=>
{
var
_a
,
_b
const
pkgPath
=
path_1
.
default
.
resolve
(
uniModulesDir
,
uniModuleDir
,
'
package.json
'
)
var
_a
,
_b
;
// 必须以 uni- 开头
if
(
!
uniModuleDir
.
startsWith
(
'
uni-
'
))
{
return
;
}
const
pkgPath
=
path_1
.
default
.
resolve
(
uniModulesDir
,
uniModuleDir
,
'
package.json
'
);
if
(
!
fs_extra_1
.
default
.
existsSync
(
pkgPath
))
{
return
return
;
}
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
.
exports
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
.
exports
;
if
(
exports
)
{
const
[
exportsImportCodes
,
exportsAssignCodes
]
=
parseExports
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
?
'
web
'
:
process
.
env
.
UNI_PLATFORM
,
`@/uni_modules/
${
uniModuleDir
}
`
,
exports
)
importCodes
.
push
(...
exportsImportCodes
)
assignCodes
.
push
(...
exportsAssignCodes
)
const
[
exportsImportCodes
,
exportsAssignCodes
]
=
parseExports
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
?
'
web
'
:
process
.
env
.
UNI_PLATFORM
,
`@/uni_modules/
${
uniModuleDir
}
`
,
exports
);
importCodes
.
push
(...
exportsImportCodes
);
assignCodes
.
push
(...
exportsAssignCodes
);
}
})
});
if
(
!
importCodes
.
length
)
{
return
''
return
''
;
}
return
`
${
importCodes
.
join
(
'
\n
'
)}
${
assignCodes
.
join
(
'
\n
'
)}
`
${
assignCodes
.
join
(
'
\n
'
)}
`
;
}
exports
.
genUniModulesExports
=
genUniModulesExports
function
parseExports
(
platform
,
source
,
exports
=
{})
{
const
rootDefines
=
{}
exports
.
genUniModulesExports
=
genUniModulesExports
;
function
parseExports
(
platform
,
source
,
exports
=
{})
{
const
rootDefines
=
{};
Object
.
keys
(
exports
).
forEach
((
name
)
=>
{
if
(
name
.
startsWith
(
'
uni
'
))
{
rootDefines
[
name
]
=
exports
[
name
]
rootDefines
[
name
]
=
exports
[
name
];
}
})
const
platformDefines
=
exports
[
platform
]
});
const
platformDefines
=
exports
[
platform
];
// 该平台不支持
if
(
platformDefines
===
false
)
{
return
[[],
[]]
return
[[],
[]];
}
return
parseDefines
(
source
,
(
0
,
merge_1
.
recursive
)(
true
,
rootDefines
,
platformDefines
))
return
parseDefines
(
source
,
(
0
,
merge_1
.
recursive
)(
true
,
rootDefines
,
platformDefines
));
}
exports
.
parseExports
=
parseExports
function
parseDefines
(
source
,
defines
=
{})
{
const
importCodes
=
[]
const
assignCodes
=
[]
exports
.
parseExports
=
parseExports
;
function
parseDefines
(
source
,
defines
=
{})
{
const
importCodes
=
[];
const
assignCodes
=
[];
Object
.
keys
(
defines
).
forEach
((
name
)
=>
{
const
[
defineImportCodes
,
defineAssignCodes
]
=
parseDefine
(
source
,
name
,
defines
[
name
])
importCodes
.
push
(...
defineImportCodes
)
assignCodes
.
push
(...
defineAssignCodes
)
})
return
[
importCodes
,
assignCodes
]
const
[
defineImportCodes
,
defineAssignCodes
]
=
parseDefine
(
source
,
name
,
defines
[
name
]);
importCodes
.
push
(...
defineImportCodes
);
assignCodes
.
push
(...
defineAssignCodes
);
});
return
[
importCodes
,
assignCodes
];
}
exports
.
parseDefines
=
parseDefines
exports
.
parseDefines
=
parseDefines
;
/**
* uni:'getBatteryInfo'
* import getBatteryInfo from '..'
...
...
@@ -81,29 +85,32 @@ exports.parseDefines = parseDefines
* @param define
* @returns
*/
function
parseDefine
(
source
,
globalObject
,
define
)
{
const
importCodes
=
[]
const
assignCodes
=
[]
function
parseDefine
(
source
,
globalObject
,
define
)
{
const
importCodes
=
[];
const
assignCodes
=
[];
if
(
typeof
define
===
'
string
'
)
{
importCodes
.
push
(
`import
${
define
}
from '
${
source
}
'`
)
assignCodes
.
push
(
`
${
globalObject
}
.
${
define
}
=
${
define
}
`
)
}
else
if
(
Array
.
isArray
(
define
))
{
importCodes
.
push
(
`import {
${
define
.
join
(
'
,
'
)}
} from '
${
source
}
'`
)
importCodes
.
push
(
`import
${
define
}
from '
${
source
}
'`
);
assignCodes
.
push
(
`
${
globalObject
}
.
${
define
}
=
${
define
}
`
);
}
else
if
(
Array
.
isArray
(
define
))
{
importCodes
.
push
(
`import {
${
define
.
join
(
'
,
'
)}
} from '
${
source
}
'`
);
define
.
forEach
((
d
)
=>
{
assignCodes
.
push
(
`
${
globalObject
}
.
${
d
}
=
${
d
}
`
)
})
}
else
{
const
keys
=
Object
.
keys
(
define
)
const
specifiers
=
[]
assignCodes
.
push
(
`
${
globalObject
}
.
${
d
}
=
${
d
}
`
);
});
}
else
{
const
keys
=
Object
.
keys
(
define
);
const
specifiers
=
[];
keys
.
forEach
((
d
)
=>
{
if
(
d
!==
define
[
d
])
{
specifiers
.
push
(
`
${
define
[
d
]}
as
${
d
}
`
)
}
else
{
specifiers
.
push
(
d
)
specifiers
.
push
(
`
${
define
[
d
]}
as
${
d
}
`
);
}
else
{
specifiers
.
push
(
d
);
}
assignCodes
.
push
(
`
${
globalObject
}
.
${
d
}
=
${
d
}
`
)
})
importCodes
.
push
(
`import {
${
specifiers
.
join
(
'
,
'
)}
} from '
${
source
}
'`
)
assignCodes
.
push
(
`
${
globalObject
}
.
${
d
}
=
${
d
}
`
);
});
importCodes
.
push
(
`import {
${
specifiers
.
join
(
'
,
'
)}
} from '
${
source
}
'`
);
}
return
[
importCodes
,
assignCodes
]
return
[
importCodes
,
assignCodes
];
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录