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

fix(plugin-legacy): use terser as the default minifier #5168

Merged
merged 1 commit into from
Oct 1, 2021

Conversation

haoqunjiang
Copy link
Member

Description

Fixes #5157

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@antfu antfu merged commit 9ee7234 into vitejs:main Oct 1, 2021
aleclarson pushed a commit to aleclarson/vite that referenced this pull request Nov 8, 2021
agriffis added a commit to agriffis/vite that referenced this pull request Dec 27, 2021
This fixes two misbehaviors of the legacy plugin:

1. Respect {minify: false} for legacy assets.
2. Don't inflict es2019/terser on non-legacy chunks.

For the first problem, we could have fixed by checking for false in
viteLegacyPlugin.config(). Unfortunately that would have left the second
problem unsolved. Without adding significant complexity to the config,
there's no easy way to use different minifiers in the build depending on
the individual chunk.

So instead we include terserPlugin() whenever minify is enabled, even
true or 'esbuild', then check the actual configuration in the plugin.
This allows the legacy plugin to inject its special override, leaving
all the non-legacy stuff intact and uncomplicated.

See also, previous attempts: vitejs#5157 vitejs#5168
agriffis added a commit to agriffis/vite that referenced this pull request Dec 27, 2021
This fixes two misbehaviors of the legacy plugin:

1. Respect {minify: false} for legacy assets.
2. Don't inflict es2019/terser on non-legacy chunks.

For the first problem, we could have fixed by checking for false in
viteLegacyPlugin.config(). Unfortunately that would have left the second
problem unsolved. Without adding significant complexity to the config,
there's no easy way to use different minifiers in the build depending on
the individual chunk.

So instead we include terserPlugin() whenever minify is enabled, even
true or 'esbuild', then check the actual configuration in the plugin.
This allows the legacy plugin to inject its special override, leaving
all the non-legacy stuff intact and uncomplicated.

See also, previous attempts: vitejs#5157 vitejs#5168
agriffis added a commit to agriffis/vite that referenced this pull request Dec 27, 2021
This fixes two misbehaviors of the legacy plugin:

1. Respect {minify: false} for legacy assets.
2. Don't inflict es2019/terser on non-legacy chunks.

For the first problem, we could have fixed by checking for false in
viteLegacyPlugin.config(). Unfortunately that would have left the second
problem unsolved. Without adding significant complexity to the config,
there's no easy way to use different minifiers in the build depending on
the individual chunk.

So instead we include terserPlugin() whenever minify is enabled, even
true or 'esbuild', then check the actual configuration in the plugin.
This allows the legacy plugin to inject its special override, leaving
all the non-legacy stuff intact and uncomplicated.

See also, previous attempts: vitejs#5157 vitejs#5168
agriffis added a commit to agriffis/vite that referenced this pull request Dec 27, 2021
This fixes two misbehaviors of the legacy plugin:

1. Respect {minify: false} for legacy assets.
2. Don't inflict es2019/terser on non-legacy chunks.

For the first problem, we could have fixed by checking for false in
viteLegacyPlugin.config(). Unfortunately that would have left the second
problem unsolved. Without adding significant complexity to the config,
there's no easy way to use different minifiers in the build depending on
the individual chunk.

So instead we include terserPlugin() whenever minify is enabled, even
true or 'esbuild', then check the actual configuration in the plugin.
This allows the legacy plugin to inject its special override, leaving
all the non-legacy stuff intact and uncomplicated.

See also, previous attempts: vitejs#5157 vitejs#5168
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vite 2.6.x + @vitejs/plugin-legacy broken behavior with esbuild minify default
3 participants