Skip to content

Commit aacf6a4

Browse files
authored
fix: tsconfig jsx overrides esbuild options, reverts #10374 (#10714)
1 parent 0ee800f commit aacf6a4

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

docs/guide/features.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ However, some libraries (e.g. [`vue`](https://github.com/vuejs/core/issues/1228)
5757

5858
#### `useDefineForClassFields`
5959

60-
Starting from Vite 2.5.0, the default value will be `true` if the TypeScript target is `ES2022` or higher including `ESNext`. It is consistent with the [behavior of `tsc` 4.3.2 and later](https://github.com/microsoft/TypeScript/pull/42663). It is also the standard ECMAScript runtime behavior.
60+
Starting from Vite 2.5.0, the default value will be `true` if the TypeScript target is `ESNext`. It is consistent with the [behavior of `tsc` 4.3.2 and later](https://github.com/microsoft/TypeScript/pull/42663). It is also the standard ECMAScript runtime behavior.
6161

6262
But it may be counter-intuitive for those coming from other programming languages or older versions of TypeScript.
6363
You can read more about the transition in the [TypeScript 3.7 release notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier).
@@ -71,13 +71,10 @@ But a few libraries haven't transitioned to this new default yet, including [`li
7171
#### Other Compiler Options Affecting the Build Result
7272

7373
- [`extends`](https://www.typescriptlang.org/tsconfig#extends)
74-
- [`alwaysStrict`](https://www.typescriptlang.org/tsconfig#alwaysStrict)
7574
- [`importsNotUsedAsValues`](https://www.typescriptlang.org/tsconfig#importsNotUsedAsValues)
76-
- [`jsx`](https://www.typescriptlang.org/tsconfig#jsx)
75+
- [`preserveValueImports`](https://www.typescriptlang.org/tsconfig#preserveValueImports)
7776
- [`jsxFactory`](https://www.typescriptlang.org/tsconfig#jsxFactory)
7877
- [`jsxFragmentFactory`](https://www.typescriptlang.org/tsconfig#jsxFragmentFactory)
79-
- [`jsxImportSource`](https://www.typescriptlang.org/tsconfig#jsxImportSource)
80-
- [`preserveValueImports`](https://www.typescriptlang.org/tsconfig#preserveValueImports)
8178

8279
If migrating your codebase to `"isolatedModules": true` is an unsurmountable effort, you may be able to get around it with a third-party plugin such as [rollup-plugin-friendly-type-imports](https://www.npmjs.com/package/rollup-plugin-friendly-type-imports). However, this approach is not officially supported by Vite.
8380

packages/vite/src/node/plugins/esbuild.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ export type ESBuildTransformResult = Omit<TransformResult, 'map'> & {
5050
type TSConfigJSON = {
5151
extends?: string
5252
compilerOptions?: {
53-
alwaysStrict?: boolean
54-
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error'
55-
jsx?: 'react' | 'react-jsx' | 'react-jsxdev' | 'preserve'
53+
target?: string
5654
jsxFactory?: string
5755
jsxFragmentFactory?: string
58-
jsxImportSource?: string
59-
preserveValueImports?: boolean
60-
target?: string
6156
useDefineForClassFields?: boolean
57+
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error'
58+
preserveValueImports?: boolean
6259
}
6360
[key: string]: any
6461
}
@@ -95,15 +92,12 @@ export async function transformWithEsbuild(
9592
// these fields would affect the compilation result
9693
// https://esbuild.github.io/content-types/#tsconfig-json
9794
const meaningfulFields: Array<keyof TSCompilerOptions> = [
98-
'alwaysStrict',
99-
'importsNotUsedAsValues',
100-
'jsx',
95+
'target',
10196
'jsxFactory',
10297
'jsxFragmentFactory',
103-
'jsxImportSource',
104-
'preserveValueImports',
105-
'target',
106-
'useDefineForClassFields'
98+
'useDefineForClassFields',
99+
'importsNotUsedAsValues',
100+
'preserveValueImports'
107101
]
108102
const compilerOptionsForFile: TSCompilerOptions = {}
109103
if (loader === 'ts' || loader === 'tsx') {

0 commit comments

Comments
 (0)