From 054eab2d9113ef99d4931070bab31caa9798f92d Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Tue, 2 Aug 2022 16:13:13 +0800 Subject: [PATCH] houhaoyu@huawei.com process importType Signed-off-by: houhaoyu Change-Id: Id298f946ec0f2ede1a3a7397673def6b5cda61ba --- compiler/build_declarations_file.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/build_declarations_file.js b/compiler/build_declarations_file.js index 877b29c..d983d7f 100644 --- a/compiler/build_declarations_file.js +++ b/compiler/build_declarations_file.js @@ -65,6 +65,8 @@ function generateTargetFile(filePath, output) { const fileName = path.resolve(output, path.basename(item)); if (item === globalTsFile || item === featureAbilityPath) { content = license + '\n\n' + processsFile(content, fileName, true); + } else { + content = processImportType(content); } fs.writeFile(fileName, content, err => { if (err) { @@ -75,6 +77,12 @@ function generateTargetFile(filePath, output) { }); } +function processImportType(content) { + return content.replace(/(import\s*\(("|'))(\.\.\/api\/[^("|')]*("|')\)\.)/g, (item, item1, item2, item3) => { + return item1 + '../../' + item3; + }) +} + function readFile(dir, fileDir) { const files = fs.readdirSync(dir); files.forEach((element) => {