1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 17module.exports = function (babel) { 18 const { types: t } = babel; 19 20 function replacePath(source) { 21 if (source) { 22 const sourceValue = source.value; 23 const prefix = '@koalaui/'; 24 if (sourceValue.startsWith(prefix)) { 25 source.value = '#koalaui/' + sourceValue.slice(prefix.length); 26 } 27 } 28 } 29 30 return { 31 visitor: { 32 ImportDeclaration(path) { 33 const source = path.node.source; 34 replacePath(source); 35 }, 36 ExportNamedDeclaration(path) { 37 const source = path.node.source; 38 replacePath(source); 39 }, 40 ExportAllDeclaration(path) { 41 const source = path.node.source; 42 replacePath(source); 43 } 44 } 45 }; 46};