fix(legacy): modernTargets
should set build.target
#20393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
modernTargets
option is when collecting polyfills for modern chunks. On the other hand,build.target
option is used when lowering by esbuild for modern chunks.This means these two options should be synced. When
renderLegacyChunks
istrue
, these two were synced. The value ofmodernTargets
were converted and set tobuild.target
.But when
renderLegacyChunks
isfalse
, that did not happen. This causes more / less polyfills to be injected than needed.This PR makes the legacy plugin to set
build.target
to the value converted frommodernTargets
option.This will cause
build.target
to be set to a lower version in applications that didn't setmodernTargets
option (before['chrome107', 'edge107', 'firefox104', 'safari16']
, after['es2020', 'edge79', 'firefox67', 'chrome64', 'safari12']
).The alternative is to set
modernTargets
based onbuild.target
. This will makemodernTargets
option no-op. Also we need to make a function that converts esbuild target syntax to browserslist syntax.refs #15506