From 519615dfcb16ffde1bd779b94d870f234d044364 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 6 Jul 2024 12:36:25 +0800 Subject: [PATCH] refactor: replace includes with logical operations --- packages/vite/src/node/build.ts | 5 ++++- packages/vite/src/node/plugins/workerImportMetaUrl.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 75f207482d010c..1ef0dcddbb93a1 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -920,7 +920,10 @@ export function resolveBuildOutputs( } outputs.forEach((output) => { - if (['umd', 'iife'].includes(output.format!) && !output.name) { + if ( + (output.format === 'umd' || output.format === 'iife') && + !output.name + ) { throw new Error( 'Entries in "build.rollupOptions.output" must specify "name" when the format is "umd" or "iife".', ) diff --git a/packages/vite/src/node/plugins/workerImportMetaUrl.ts b/packages/vite/src/node/plugins/workerImportMetaUrl.ts index 22a5de2ec67b06..4065c6470aca98 100644 --- a/packages/vite/src/node/plugins/workerImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/workerImportMetaUrl.ts @@ -82,7 +82,10 @@ function getWorkerType(raw: string, clean: string, i: number): WorkerType { } const workerOpts = parseWorkerOptions(workerOptString, commaIndex + 1) - if (workerOpts.type && ['classic', 'module'].includes(workerOpts.type)) { + if ( + workerOpts.type && + (workerOpts.type === 'module' || workerOpts.type === 'classic') + ) { return workerOpts.type }