Skip to content

Commit

Permalink
fix: oxc esbuild transform option compat
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jan 10, 2025
1 parent 2814e17 commit a104db3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
mergeWithDefaults,
normalizePath,
partialEncodeURIPath,
unique,
} from './utils'
import { perEnvironmentPlugin, resolveEnvironmentPlugins } from './plugin'
import { manifestPlugin } from './plugins/manifest'
Expand Down Expand Up @@ -434,6 +435,11 @@ export function resolveBuildEnvironmentOptions(
if (merged.target === 'modules') {
merged.target = ESBUILD_MODULES_TARGET
}
// dedupe target
if (Array.isArray(merged.target)) {
// esbuild allowed duplicate targets but oxc does not
merged.target = unique(merged.target)
}

// normalize false string into actual false
if ((merged.minify as string) === 'false') {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/oxc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export async function transformWithOxc(
const esTargetIndex = target.findIndex((t) =>
t.toLowerCase().startsWith('es'),
)
if (esTargetIndex > 0) {
if (esTargetIndex >= 0) {
const esTargetTrimmed = target[esTargetIndex].toLowerCase().slice(2)
if (
esTargetTrimmed === 'next' ||
Expand Down

0 comments on commit a104db3

Please sign in to comment.