[GH-ISSUE #774] Support experimental.swcEnvOptions config option #170

Closed
opened 2026-05-06 12:37:51 +02:00 by BreizhHardware · 0 comments

Originally created by @github-actions[bot] on GitHub (Apr 4, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/774

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:

  1. 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.
  2. 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)
Originally created by @github-actions[bot] on GitHub (Apr 4, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/774 ## 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`](https://github.com/vercel/next.js/commit/2bf38b01154ab1b3b0de0e4a5094f4cffb6c20d2) **PR:** [#92272](https://github.com/vercel/next.js/pull/92272) ## Config Shape ```ts 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: 1. **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. 2. **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)
BreizhHardware 2026-05-06 12:37:51 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#170
No description provided.