Skip to content

Commit

Permalink
feat(plugin-legacy): add modernTargets option warning
Browse files Browse the repository at this point in the history
  • Loading branch information
undermoonn committed Jan 12, 2024
1 parent 002b649 commit c0f3f81
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
}

let overriddenBuildTarget = false
let overriddenDefaultModernTargets = false
const legacyConfigPlugin: Plugin = {
name: 'vite:legacy-config',

Expand All @@ -207,6 +208,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
// Vite's default target browsers are **not** the same.
// See https://github.com/vitejs/vite/pull/10052#issuecomment-1242076461
overriddenBuildTarget = config.build.target !== undefined
overriddenDefaultModernTargets = options.modernTargets !== undefined
config.build.target = options.modernTargets
? resolveToEsbuildTarget(browserslist(options.modernTargets))
: modernTargetsEsbuild
Expand All @@ -230,6 +232,13 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
),
)
}
if (overriddenDefaultModernTargets) {
config.logger.warn(
colors.yellow(
`plugin-legacy overrode builtin targets of modern chunks. Some versions of browsers between legacy and modern maybe not be supported.`,
),
)
}
},
}

Expand Down

0 comments on commit c0f3f81

Please sign in to comment.