diff --git a/packages/uni-cli-shared/src/resolve.ts b/packages/uni-cli-shared/src/resolve.ts index f74a2f4e4c431634e299fb965583a39fd91dc4b4..94f3b092091c25c206c79183d8024e73a5dcda78 100644 --- a/packages/uni-cli-shared/src/resolve.ts +++ b/packages/uni-cli-shared/src/resolve.ts @@ -201,13 +201,23 @@ function resolveUtsFile( } export function resolveUTSCompiler(): typeof UTSCompiler { + let compilerPath: string = '' if (isInHBuilderX()) { - return require(path.resolve( - process.env.UNI_HBUILDERX_PLUGINS, - 'uniapp-uts' - )) + try { + compilerPath = require.resolve( + path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uniapp-uts') + ) + } catch (e) {} + } + if (!compilerPath) { + try { + compilerPath = require.resolve('@dcloudio/uni-uts-v1', { + paths: [process.env.UNI_CLI_CONTEXT], + }) + } catch (e) {} + } + if (!compilerPath) { + throw 'uts compiler is not found' } - return require(require.resolve('@dcloudio/uni-uts-v1', { - paths: [process.env.UNI_CLI_CONTEXT], - })) + return require(compilerPath) } diff --git a/packages/uni-cloud/lib/uni.plugin.js b/packages/uni-cloud/lib/uni.plugin.js index ad6e4504513d2abed738904e6b25bd62103299ef..60b7b6ebfed13c699efef5352f4709c3d6382e5f 100644 --- a/packages/uni-cloud/lib/uni.plugin.js +++ b/packages/uni-cloud/lib/uni.plugin.js @@ -150,8 +150,7 @@ exports.default = () => [ const isSecureNetworkEnabled = (0, uni_cli_shared_1.isEnableSecureNetwork)(inputDir, platform); return { define: { - 'process.env.UNI_SECURE_NETWORK_ENABLE': isSecureNetworkEnabled, - 'process.env.UNI_SECURE_NETWORK_CONFIG': process.env.UNI_SECURE_NETWORK_CONFIG, + 'process.env.UNI_SECURE_NETWORK': isSecureNetworkEnabled, }, }; }, diff --git a/packages/uni-uts-v1/src/kotlin.ts b/packages/uni-uts-v1/src/kotlin.ts index e421fff425c0f7a67cd63a6c3651a1e94ef13de6..2fc56e8992fa24caf6363d9222de9436f5405bc5 100644 --- a/packages/uni-uts-v1/src/kotlin.ts +++ b/packages/uni-uts-v1/src/kotlin.ts @@ -152,7 +152,7 @@ function resolveSourceMapFile(outputDir: string, kotlinFile: string) { async function compile(filename: string) { if (!process.env.UNI_HBUILDERX_PLUGINS) { - return console.error('process.env.UNI_HBUILDERX_PLUGINS is not found') + throw 'process.env.UNI_HBUILDERX_PLUGINS is not found' } const { bundle, UtsTarget } = getUtsCompiler() const inputDir = process.env.UNI_INPUT_DIR diff --git a/packages/uni-uts-v1/src/swift.ts b/packages/uni-uts-v1/src/swift.ts index b8eb54aab6f06eef3fa89a050e5ec5ff8286aba3..2deebe190c324d2c3e8f131c9430b51689b5838f 100644 --- a/packages/uni-uts-v1/src/swift.ts +++ b/packages/uni-uts-v1/src/swift.ts @@ -40,7 +40,7 @@ export async function runSwiftDev(_filename: string) {} async function compile(filename: string) { if (!process.env.UNI_HBUILDERX_PLUGINS) { - return console.error('process.env.UNI_HBUILDERX_PLUGINS is not found') + throw 'process.env.UNI_HBUILDERX_PLUGINS is not found' } const { bundle, UtsTarget } = getUtsCompiler() const inputDir = process.env.UNI_INPUT_DIR