diff --git a/packages/uni-cli-shared/lib/uts/uni_modules.js b/packages/uni-cli-shared/lib/uts/uni_modules.js index 1c9e64b0d77ffa918eedaf4247e6f41009285d8b..47e7fd747d18781193092018e5928e0b220a98ce 100644 --- a/packages/uni-cli-shared/lib/uts/uni_modules.js +++ b/packages/uni-cli-shared/lib/uts/uni_modules.js @@ -63,6 +63,9 @@ exports.parseUniExtApis = parseUniExtApis; * @returns */ function parseInjects(vite = true, platform, language, source, uniModuleRootDir, exports = {}) { + if (platform === 'app-plus') { + platform = 'app'; + } let rootDefines = {}; Object.keys(exports).forEach((name) => { if (name.startsWith('uni')) { @@ -71,10 +74,17 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir, }); const injects = {}; if (Object.keys(rootDefines).length) { - const hasPlatformFile = uniModuleRootDir + let hasPlatformFile = uniModuleRootDir ? fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'index.uts')) || fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', platform)) : true; + if (!hasPlatformFile) { + if (platform === 'app') { + hasPlatformFile = + fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-android')) || + fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-ios')); + } + } for (const key in rootDefines) { Object.assign(injects, parseInject(vite, platform, language, source, 'uni', rootDefines[key], hasPlatformFile)); }