diff --git a/compiler/src/import_path_expand.ts b/compiler/src/import_path_expand.ts index 9d1b8766139f79645777f1a0b5d3f1b39966273f..e856e6fa3c8e95cf0857173212a424cf34ebb6ba 100644 --- a/compiler/src/import_path_expand.ts +++ b/compiler/src/import_path_expand.ts @@ -43,7 +43,7 @@ export function expandAllImportPaths(checker: ts.TypeChecker, rollupObejct: Obje const visitor: ts.Visitor = (node: ts.Node): ts.VisitResult => { if (ts.isImportDeclaration(node)) { const result: ts.ImportDeclaration[] = transformImportDecl(node, checker, exclude, - rollupObejct.share.projectConfig); + Object.assign(rollupObejct.share.projectConfig, rollupObejct.share.arkProjectConfig)); return result.length > 0 ? result : node; } return node; diff --git a/compiler/src/interop/src/import_path_expand.ts b/compiler/src/interop/src/import_path_expand.ts index 9d1b8766139f79645777f1a0b5d3f1b39966273f..e856e6fa3c8e95cf0857173212a424cf34ebb6ba 100644 --- a/compiler/src/interop/src/import_path_expand.ts +++ b/compiler/src/interop/src/import_path_expand.ts @@ -43,7 +43,7 @@ export function expandAllImportPaths(checker: ts.TypeChecker, rollupObejct: Obje const visitor: ts.Visitor = (node: ts.Node): ts.VisitResult => { if (ts.isImportDeclaration(node)) { const result: ts.ImportDeclaration[] = transformImportDecl(node, checker, exclude, - rollupObejct.share.projectConfig); + Object.assign(rollupObejct.share.projectConfig, rollupObejct.share.arkProjectConfig)); return result.length > 0 ? result : node; } return node; diff --git a/compiler/test/ark_compiler_ut/common/import_path_expand.test.ts b/compiler/test/ark_compiler_ut/common/import_path_expand.test.ts index 53145d3fbf33f3c0608b9b7c48defaf9fde5bf0b..1307af58195e73ac7d162949527f9f92544ecff3 100644 --- a/compiler/test/ark_compiler_ut/common/import_path_expand.test.ts +++ b/compiler/test/ark_compiler_ut/common/import_path_expand.test.ts @@ -393,6 +393,8 @@ const rollupObejct = { expandImportPath: baseConfig, depName2DepInfo: new Map(), packageDir: 'oh_modules', + }, + arkProjectConfig: { hspNameOhmMap: {}, harNameOhmMap: {} } @@ -584,7 +586,7 @@ mocha.describe('test import_path_expand file api', () => { }); mocha.it('4-5: should preserve import when module in hspNameOhmMap', () => { - rollupObejct.share.projectConfig.hspNameOhmMap = { 'hspPkg': 'hspPkg.ohm' }; + rollupObejct.share.arkProjectConfig.hspNameOhmMap = { 'hspPkg': 'hspPkg.ohm' }; const { program, testSourceFile } = createMultiSymbolProgram(CASE_4_5_TEST, CASE_4_5_FILES, ''); const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], program.getCompilerOptions()).transformed[0]; @@ -592,11 +594,11 @@ mocha.describe('test import_path_expand file api', () => { const result = printer.printFile(transformed); expect(result === EXPECT_4_5).to.be.true; - rollupObejct.share.projectConfig.hspNameOhmMap = {}; + rollupObejct.share.arkProjectConfig.hspNameOhmMap = {}; }); mocha.it('4-6: should preserve import when module in harNameOhmMap', () => { - rollupObejct.share.projectConfig.harNameOhmMap = { 'harPkg': 'harPkg.ohm' }; + rollupObejct.share.arkProjectConfig.harNameOhmMap = { 'harPkg': 'harPkg.ohm' }; const { program, testSourceFile } = createMultiSymbolProgram(CASE_4_6_TEST, CASE_4_6_FILES, ''); const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], program.getCompilerOptions()).transformed[0]; @@ -604,7 +606,7 @@ mocha.describe('test import_path_expand file api', () => { const result = printer.printFile(transformed); expect(result === EXPECT_4_6).to.be.true; - rollupObejct.share.projectConfig.harNameOhmMap = {}; + rollupObejct.share.arkProjectConfig.harNameOhmMap = {}; }); mocha.it('4-7: should preserve import when module in exclude list', () => {