简体   繁体   中英

Remove core-js from nextjs bundle

I am trying to reduce nextjs project's bundle sizes. There is a core-js bundle for polyfills. I want to remove this core-js from the main bundle size. It has 50KB of size.

I tried to use custom babel configuration like this:

    {
        "presets": [
            [
                "next/babel",
                {
                    "useBuiltIns": "usage",
                    "corejs": "3"
                }
            ]
        

]
}

But it didn't help.

How can I remove the corejs from a NextJS project?

Any help will be appreciated.

Thanks

Try this:

{
  "presets": [
    [
      "next/babel"
    ]
  ]
}

source: https://github.com/vercel/next.js/issues/6931#issuecomment-633247029

Alternatively:

{
  "presets": [
    [
      "next/babel",
      {
        "preset-env": {
          "useBuiltIns": "entry",
          "corejs": "3"
        }
      }
    ]
  ]
}

source: https://github.com/vercel/next.js/issues/6931#issuecomment-633158748

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM