Skip to content

Commit

Permalink
refactor(legacy)!: remove ignoreBrowserslistConfig option (#14429)
Browse files Browse the repository at this point in the history
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
  • Loading branch information
sapphi-red and bluwy authored Sep 22, 2023
1 parent 995c4b6 commit 941bb16
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
14 changes: 2 additions & 12 deletions packages/plugin-legacy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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[]`
Expand All @@ -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[]`
Expand Down
16 changes: 4 additions & 12 deletions packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
],
[
(await import('@babel/preset-env')).default,
createBabelPresetEnvOptions(targets, {
needPolyfills,
ignoreBrowserslistConfig: options.ignoreBrowserslistConfig,
}),
createBabelPresetEnvOptions(targets, { needPolyfills }),
],
],
})
Expand Down Expand Up @@ -641,9 +638,7 @@ export async function detectPolyfills(
presets: [
[
(await import('@babel/preset-env')).default,
createBabelPresetEnvOptions(targets, {
ignoreBrowserslistConfig: true,
}),
createBabelPresetEnvOptions(targets, {}),
],
],
})
Expand All @@ -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,
Expand All @@ -680,7 +672,7 @@ function createBabelPresetEnvOptions(
}
: undefined,
shippedProposals: true,
ignoreBrowserslistConfig,
ignoreBrowserslistConfig: true,
}
}

Expand Down
4 changes: 0 additions & 4 deletions packages/plugin-legacy/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ export interface Options {
* default: 'defaults'
*/
targets?: string | string[] | { [key: string]: string }
/**
* default: false
*/
ignoreBrowserslistConfig?: boolean
/**
* default: true
*/
Expand Down

0 comments on commit 941bb16

Please sign in to comment.