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) => {