@@ -102,6 +102,7 @@ interface Meta {
102102 }
103103}
104104export interface GenProxyCodeOptions {
105+ platform ?: 'app-android' | 'app-ios'
105106 is_uni_modules : boolean
106107 id : string
107108 name : string
@@ -695,6 +696,7 @@ async function parseModuleDecls(module: string, options: GenProxyCodeOptions) {
695696 // 优先合并 ios + android,如果没有,查找根目录 index.uts
696697 const iosDecls = (
697698 await parseFile (
699+ options . platform === 'app-ios' ,
698700 resolvePlatformIndex ( 'app-ios' , module , options ) ,
699701 options ,
700702 options . iosPreprocessor
@@ -710,6 +712,7 @@ async function parseModuleDecls(module: string, options: GenProxyCodeOptions) {
710712 } )
711713 const androidDecls = (
712714 await parseFile (
715+ options . platform === 'app-android' ,
713716 resolvePlatformIndex ( 'app-android' , module , options ) ,
714717 options ,
715718 options . androidPreprocessor
@@ -730,7 +733,7 @@ async function parseModuleDecls(module: string, options: GenProxyCodeOptions) {
730733 const decls = mergeDecls ( androidDecls , iosDecls )
731734 // 如果没有平台特有,查找 root index.uts
732735 if ( ! decls . length ) {
733- return await parseFile ( resolveRootIndex ( module , options ) , options )
736+ return await parseFile ( true , resolveRootIndex ( module , options ) , options )
734737 }
735738 return decls
736739}
@@ -818,6 +821,7 @@ function mergeDecls(from: ProxyDecl[], to: ProxyDecl[]) {
818821}
819822
820823async function parseFile (
824+ checkEmpty : boolean ,
821825 filename : string | undefined | false ,
822826 options : GenProxyCodeOptions ,
823827 preprocessor ?: SyncUniModulesFilePreprocessor
@@ -828,14 +832,10 @@ async function parseFile(
828832 if ( fs . existsSync ( filename ) ) {
829833 const code = fs . readFileSync ( filename , 'utf8' )
830834 if ( ! code || code . trim ( ) === '' ) {
831- console . error (
832- parseUTSSyntaxError (
833- new Error (
834- `文件内容不能为空: ${ relative ( filename , options . inputDir ! ) } `
835- ) ,
836- process . env . UNI_INPUT_DIR
837- )
838- )
835+ if ( checkEmpty ) {
836+ console . error ( `error: 文件内容为空,请检查。` )
837+ console . error ( `at ${ relative ( filename , options . inputDir ! ) } :1` )
838+ }
839839 return [ ]
840840 }
841841 return parseCode (
0 commit comments