Skip to content

Commit

Permalink
refactor: esbuild no longer uses its target to set default value of `…
Browse files Browse the repository at this point in the history
…useDefineForClassFields`
  • Loading branch information
sapphi-red committed Jun 15, 2023
1 parent c15c155 commit f4a27dd
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,6 @@ export async function transformWithEsbuild(
...tsconfigRaw?.compilerOptions,
}

// esbuild derives `useDefineForClassFields` from `target` instead of `tsconfig.compilerOptions.target`
// https://github.com/evanw/esbuild/issues/2584
// but we want `useDefineForClassFields` to be derived from `tsconfig.compilerOptions.target`
if (compilerOptions.useDefineForClassFields === undefined) {
const lowercaseTarget = compilerOptions.target?.toLowerCase() ?? 'es3'
if (lowercaseTarget.startsWith('es')) {
const esVersion = lowercaseTarget.slice(2)
compilerOptions.useDefineForClassFields =
esVersion === 'next' || +esVersion >= 2022
} else {
compilerOptions.useDefineForClassFields = false
}
}

// esbuild uses tsconfig fields when both the normal options and tsconfig was set
// but we want to prioritize the normal options
if (options) {
Expand Down

0 comments on commit f4a27dd

Please sign in to comment.