From f8c6031c177c9c44e4572cb84dc2d1776b897069 Mon Sep 17 00:00:00 2001 From: lizhouze Date: Fri, 24 Jun 2022 15:53:45 +0800 Subject: [PATCH] fixed 4648524 from https://gitee.com/kage1/third_party_weex-loader/pulls/79 lizhouze@huawei.com Signed-off-by: lizhouze --- src/util.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index 92c9fc8..c849947 100644 --- a/src/util.js +++ b/src/util.js @@ -26,6 +26,7 @@ import { SourceMapConsumer } from 'source-map' +const { systemModules } = require('../main.product') const { DEVICE_LEVEL } = require('./lite/lite-enum') export const useOSFiles = new Set(); @@ -280,8 +281,11 @@ export function parseRequireModule (source, resourcePath) { let requireStatements = source.match(requireReg) if (requireStatements && requireStatements.length) { for (let requireStatement of requireStatements) { - if (requireStatement.match(REG_SYSTEM)) { - source = source.replace(requireStatement, requireStatement.replace('require', 'requireModule')) + const requireStatementExec = /\((\"|\')(.+)(\"|\')\)/.exec(requireStatement); + if (requireStatement.match(REG_SYSTEM) && requireStatementExec && requireStatementExec.length > 3) { + if (systemModules.length == 0 || systemModules.includes(requireStatementExec[2] + '.d.ts')) { + source = source.replace(requireStatement, requireStatement.replace('require', 'requireModule')); + } } } } -- Gitee