From d4a37e1ebbfa79e4582c6fd6c42644184c9f3cb6 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 12 Apr 2022 16:42:28 +0800 Subject: [PATCH] refactor: let esbuild handle the `target` and `useDefineForClassFields` logic esbuild has added the corresponding handling logic in 0.14.0 and 0.14.35: - https://github.com/evanw/esbuild/releases/tag/v0.14.0 - https://github.com/evanw/esbuild/releases/tag/v0.14.35 So our workaround is no longer needed. --- packages/vite/src/node/plugins/esbuild.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index db216c7d6b0d77..c982b4e61f30c8 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -81,6 +81,7 @@ export async function transformWithEsbuild( // these fields would affect the compilation result // https://esbuild.github.io/content-types/#tsconfig-json const meaningfulFields: Array = [ + 'target', 'jsxFactory', 'jsxFragmentFactory', 'useDefineForClassFields', @@ -98,17 +99,9 @@ export async function transformWithEsbuild( compilerOptionsForFile[field] = loadedCompilerOptions[field] } } - - // align with TypeScript 4.3 - // https://github.com/microsoft/TypeScript/pull/42663 - if (loadedCompilerOptions.target?.toLowerCase() === 'esnext') { - compilerOptionsForFile.useDefineForClassFields = - loadedCompilerOptions.useDefineForClassFields ?? true - } } tsconfigRaw = { - ...tsconfigRaw, compilerOptions: { ...compilerOptionsForFile, ...tsconfigRaw?.compilerOptions