From 6fc103eb5ba211442a454a5192bf46529536d89e Mon Sep 17 00:00:00 2001 From: alex8088 <244096523@qq.com> Date: Sat, 10 Oct 2026 23:00:29 +0800 Subject: [PATCH] perf: short-circuit bytecode detection in builds --- src/build.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/build.ts b/src/build.ts index 25106fd..98b5a74 100644 --- a/src/build.ts +++ b/src/build.ts @@ -4,8 +4,9 @@ import { BytecodeCompiler } from './bytecodeCompiler' import { BYTECODE_BUILD_PLUGIN_NAME } from './constants' import { asyncFlatten } from './utils' -async function useBytecode(config?: MainViteConfig | PreloadViteConfig): Promise { +async function usesBytecode(config?: MainViteConfig | PreloadViteConfig): Promise { if (!config) return false + if (config.build?.bytecode) return true const plugins = await asyncFlatten(config.plugins || []) return plugins.some(plugin => plugin && typeof plugin === 'object' && plugin.name === 'vite:bytecode') } @@ -29,9 +30,7 @@ export async function build(inlineConfig: InlineConfig = {}): Promise { return } - const mainBytecode = await useBytecode(config.config.main) - const preloadBytecode = await useBytecode(config.config.preload) - const hasBytecode = mainBytecode || preloadBytecode + const hasBytecode = (await usesBytecode(config.config.main)) || (await usesBytecode(config.config.preload)) const buildTargets = async (): Promise => { // Build targets in order: main -> preload -> renderer