From e53d815a43d627806d4d05220a1f4c40c687c65d Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Thu, 21 Sep 2023 18:18:59 +0900 Subject: [PATCH 1/2] refactor(legacy)!: remove `ignoreBrowserslistConfig` option --- 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..38bd0e60ac2edc 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 browserslit 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 eb5dbb0752756f..fe9c89284d429e 100644 --- a/packages/plugin-legacy/src/index.ts +++ b/packages/plugin-legacy/src/index.ts @@ -454,10 +454,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] { ], [ (await import('@babel/preset-env')).default, - createBabelPresetEnvOptions(targets, { - needPolyfills, - ignoreBrowserslistConfig: options.ignoreBrowserslistConfig, - }), + createBabelPresetEnvOptions(targets, { needPolyfills }), ], ], }) @@ -633,9 +630,7 @@ export async function detectPolyfills( presets: [ [ (await import('@babel/preset-env')).default, - createBabelPresetEnvOptions(targets, { - ignoreBrowserslistConfig: true, - }), + createBabelPresetEnvOptions(targets, {}), ], ], }) @@ -654,10 +649,7 @@ export async function detectPolyfills( function createBabelPresetEnvOptions( targets: any, - { - needPolyfills = true, - ignoreBrowserslistConfig, - }: { needPolyfills?: boolean; ignoreBrowserslistConfig?: boolean }, + { needPolyfills = true }: { needPolyfills?: boolean }, ) { return { targets, @@ -672,7 +664,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 */ From eec0c9787beb87e2f7c1efd095d298e82b3ddf58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 23 Sep 2023 00:03:59 +0900 Subject: [PATCH 2/2] chore: fix typo, thanks blu Co-authored-by: Bjorn Lu --- packages/plugin-legacy/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-legacy/README.md b/packages/plugin-legacy/README.md index 38bd0e60ac2edc..0e40ccfe55f121 100644 --- a/packages/plugin-legacy/README.md +++ b/packages/plugin-legacy/README.md @@ -44,7 +44,7 @@ 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 browserslit config sources](https://github.com/browserslist/browserslist#queries) and then fallback to the default value. + 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`