Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(legacy)!: remove ignoreBrowserslistConfig option #14429

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 browserslit config sources](https://github.com/browserslist/browserslist#queries) and then fallback to the default value.
sapphi-red marked this conversation as resolved.
Show resolved Hide resolved

### `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 @@ -454,10 +454,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 @@ -633,9 +630,7 @@ export async function detectPolyfills(
presets: [
[
(await import('@babel/preset-env')).default,
createBabelPresetEnvOptions(targets, {
ignoreBrowserslistConfig: true,
}),
createBabelPresetEnvOptions(targets, {}),
],
],
})
Expand All @@ -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,
Expand All @@ -672,7 +664,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