Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: esbuild handles target and useDefineForClassFields #7698

Merged
merged 1 commit into from Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions packages/vite/src/node/plugins/esbuild.ts
Expand Up @@ -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<keyof TSCompilerOptions> = [
'target',
'jsxFactory',
'jsxFragmentFactory',
'useDefineForClassFields',
Expand All @@ -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,
Niputi marked this conversation as resolved.
Show resolved Hide resolved
compilerOptions: {
...compilerOptionsForFile,
...tsconfigRaw?.compilerOptions
Expand Down