vitejs / vite-plugin-react-swc

Speed up your Vite dev server with SWC
MIT License
774 stars 49 forks source link

how to enable core-js polyfill at build time ? #215

Closed vaynevayne closed 5 days ago

vaynevayne commented 2 weeks ago

在开发时会将 Babel 替换为 SWC。在构建时,若使用了插件则会使用 SWC+esbuild,若没有使用插件则仅会用到 esbuild。对不需要非标准 React 扩展的大型项目,冷启动和模块热替换(HMR)将会有显著提升。

The document says to use the plug-in, how do I use it? I couldn't find a core-js plugin

react({ plugins: [["@swc/plugin-styled-components", {}]] })
vaynevayne commented 1 week ago

In addition, I found that the browser list is supported in the swc document, which means that the polyfill of core-js can be filled. How can this plug-in enable this wide function? Because the vite document says that padding is not supported, I feel confused. What is the correct answer?

ArnaudBarre commented 1 week ago

I think you should look into for that: https://www.npmjs.com/package/@vitejs/plugin-legacy

ArnaudBarre commented 5 days ago

I'm closing this as polyfill are out of scope of this plugin, this something that should be enabled at the bundler level, this plugin only process user code.