1.0工具链解决引入不存在文件报错问题

Signed-off-by: fanjiaojiao <fanjiaojiao@huawei.com>
This commit is contained in:
fanjiaojiao 2023-08-08 10:45:25 +08:00
parent 8faef29aa1
commit d91eac95ef

View File

@ -286,7 +286,8 @@ export function parseRequireModule (source, resourcePath) {
for (let requireStatement of requireStatements) {
const requireStatementExec = /\((\"|\')(.+)(\"|\')\)/.exec(requireStatement);
if (requireStatement.match(REG_SYSTEM) && requireStatementExec && requireStatementExec.length > 3) {
if (systemModules.length == 0 || systemModules.includes(requireStatementExec[2] + '.d.ts')) {
if (systemModules.length == 0 || systemModules.includes(requireStatementExec[2] + '.d.ts') ||
process.env.DEVICE_LEVEL === 'lite') {
source = source.replace(requireStatement, requireStatement.replace('require', 'requireModule'));
}
}