Next.js Change
Next.js added a new experimental.swcEnvOptions config option that exposes SWC's preset-env configuration for automatic polyfill injection (core-js usage/entry mode).
Commit: 2bf38b0
PR: #92272
Config Shape
experimental: {
swcEnvOptions?: {
mode?: 'usage' | 'entry'
coreJs?: string
skip?: string[]
include?: string[]
exclude?: string[]
shippedProposals?: boolean
forceAllTransforms?: boolean
debug?: boolean
loose?: boolean
}
}
Impact on vinext
vinext uses Vite for transforms, not SWC's webpack loader, so the polyfill injection behavior itself doesn't directly apply. However:
- Config validation: If vinext validates
next.config.js and rejects unknown keys under experimental, users with this option will get errors. vinext should accept (and ignore) this key.
- Polyfill parity: Users migrating from Next.js who rely on
swcEnvOptions for automatic core-js polyfills will lose that functionality on vinext. We should document this gap or explore a Vite-compatible equivalent (e.g., a Vite plugin for core-js injection based on browserslist targets).
Suggested Action
- Accept
experimental.swcEnvOptions in config without erroring
- Emit a warning that polyfill injection is not yet supported in vinext
- Consider future support via a Vite plugin (e.g.,
vite-plugin-babel with @babel/preset-env or a dedicated polyfill plugin)
Next.js Change
Next.js added a new
experimental.swcEnvOptionsconfig option that exposes SWC's preset-env configuration for automatic polyfill injection (core-jsusage/entrymode).Commit:
2bf38b0PR: #92272
Config Shape
Impact on vinext
vinext uses Vite for transforms, not SWC's webpack loader, so the polyfill injection behavior itself doesn't directly apply. However:
next.config.jsand rejects unknown keys underexperimental, users with this option will get errors. vinext should accept (and ignore) this key.swcEnvOptionsfor automatic core-js polyfills will lose that functionality on vinext. We should document this gap or explore a Vite-compatible equivalent (e.g., a Vite plugin for core-js injection based on browserslist targets).Suggested Action
experimental.swcEnvOptionsin config without erroringvite-plugin-babelwith@babel/preset-envor a dedicated polyfill plugin)