diff --git a/docs/guide/features.md b/docs/guide/features.md index f41e5d8ce9bd31..0f69035a71dea5 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -57,7 +57,7 @@ However, some libraries (e.g. [`vue`](https://github.com/vuejs/core/issues/1228) #### `useDefineForClassFields` -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. +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. But it may be counter-intuitive for those coming from other programming languages or older versions of TypeScript. 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 #### Other Compiler Options Affecting the Build Result - [`extends`](https://www.typescriptlang.org/tsconfig#extends) -- [`alwaysStrict`](https://www.typescriptlang.org/tsconfig#alwaysStrict) - [`importsNotUsedAsValues`](https://www.typescriptlang.org/tsconfig#importsNotUsedAsValues) -- [`jsx`](https://www.typescriptlang.org/tsconfig#jsx) +- [`preserveValueImports`](https://www.typescriptlang.org/tsconfig#preserveValueImports) - [`jsxFactory`](https://www.typescriptlang.org/tsconfig#jsxFactory) - [`jsxFragmentFactory`](https://www.typescriptlang.org/tsconfig#jsxFragmentFactory) -- [`jsxImportSource`](https://www.typescriptlang.org/tsconfig#jsxImportSource) -- [`preserveValueImports`](https://www.typescriptlang.org/tsconfig#preserveValueImports) 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. diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index cb1899eabc5e1c..43c319f2713761 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -50,15 +50,12 @@ export type ESBuildTransformResult = Omit & { type TSConfigJSON = { extends?: string compilerOptions?: { - alwaysStrict?: boolean - importsNotUsedAsValues?: 'remove' | 'preserve' | 'error' - jsx?: 'react' | 'react-jsx' | 'react-jsxdev' | 'preserve' + target?: string jsxFactory?: string jsxFragmentFactory?: string - jsxImportSource?: string - preserveValueImports?: boolean - target?: string useDefineForClassFields?: boolean + importsNotUsedAsValues?: 'remove' | 'preserve' | 'error' + preserveValueImports?: boolean } [key: string]: any } @@ -95,15 +92,12 @@ export async function transformWithEsbuild( // these fields would affect the compilation result // https://esbuild.github.io/content-types/#tsconfig-json const meaningfulFields: Array = [ - 'alwaysStrict', - 'importsNotUsedAsValues', - 'jsx', + 'target', 'jsxFactory', 'jsxFragmentFactory', - 'jsxImportSource', - 'preserveValueImports', - 'target', - 'useDefineForClassFields' + 'useDefineForClassFields', + 'importsNotUsedAsValues', + 'preserveValueImports' ] const compilerOptionsForFile: TSCompilerOptions = {} if (loader === 'ts' || loader === 'tsx') {