From 941bb1610c9c9576e0b5738c9075b3eb2f16a357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 23 Sep 2023 00:45:01 +0900 Subject: [PATCH] refactor(legacy)!: remove `ignoreBrowserslistConfig` option (#14429) Co-authored-by: Bjorn Lu --- packages/plugin-legacy/README.md | 14 ++------------ packages/plugin-legacy/src/index.ts | 16 ++++------------ packages/plugin-legacy/src/types.ts | 4 ---- 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/packages/plugin-legacy/README.md b/packages/plugin-legacy/README.md index 37700afae156e3..0e40ccfe55f121 100644 --- a/packages/plugin-legacy/README.md +++ b/packages/plugin-legacy/README.md @@ -44,6 +44,8 @@ npm add -D terser The query is also [Browserslist compatible](https://github.com/browserslist/browserslist). See [Browserslist Best Practices](https://github.com/browserslist/browserslist#best-practices) for more details. + If it's not set, plugin-legacy will load [the browserslist config sources](https://github.com/browserslist/browserslist#queries) and then fallback to the default value. + ### `polyfills` - **Type:** `boolean | string[]` @@ -63,18 +65,6 @@ npm add -D terser Note: if additional polyfills are needed for both the modern and legacy chunks, they can simply be imported in the application source code. -### `ignoreBrowserslistConfig` - -- **Type:** `boolean` -- **Default:** `false` - - `@babel/preset-env` automatically detects [`browserslist` config sources](https://github.com/browserslist/browserslist#browserslist-): - - - `browserslist` field in `package.json` - - `.browserslistrc` file in cwd. - - Set to `true` to ignore these sources. - ### `modernPolyfills` - **Type:** `boolean | string[]` diff --git a/packages/plugin-legacy/src/index.ts b/packages/plugin-legacy/src/index.ts index c07df1da56740a..5c20c22bc03d04 100644 --- a/packages/plugin-legacy/src/index.ts +++ b/packages/plugin-legacy/src/index.ts @@ -461,10 +461,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { ], [ (await import('@babel/preset-env')).default, - createBabelPresetEnvOptions(targets, { - needPolyfills, - ignoreBrowserslistConfig: options.ignoreBrowserslistConfig, - }), + createBabelPresetEnvOptions(targets, { needPolyfills }), ], ], }) @@ -641,9 +638,7 @@ export async function detectPolyfills( presets: [ [ (await import('@babel/preset-env')).default, - createBabelPresetEnvOptions(targets, { - ignoreBrowserslistConfig: true, - }), + createBabelPresetEnvOptions(targets, {}), ], ], }) @@ -662,10 +657,7 @@ export async function detectPolyfills( function createBabelPresetEnvOptions( targets: any, - { - needPolyfills = true, - ignoreBrowserslistConfig, - }: { needPolyfills?: boolean; ignoreBrowserslistConfig?: boolean }, + { needPolyfills = true }: { needPolyfills?: boolean }, ) { return { targets, @@ -680,7 +672,7 @@ function createBabelPresetEnvOptions( } : undefined, shippedProposals: true, - ignoreBrowserslistConfig, + ignoreBrowserslistConfig: true, } } diff --git a/packages/plugin-legacy/src/types.ts b/packages/plugin-legacy/src/types.ts index 0731d7936d91f8..954617d900d241 100644 --- a/packages/plugin-legacy/src/types.ts +++ b/packages/plugin-legacy/src/types.ts @@ -3,10 +3,6 @@ export interface Options { * default: 'defaults' */ targets?: string | string[] | { [key: string]: string } - /** - * default: false - */ - ignoreBrowserslistConfig?: boolean /** * default: true */