optimizePackageImports

某些包可能会导出数百甚至数千个模块,这可能导致开发和生产环境下的性能问题。

将包添加到 experimental.optimizePackageImports 后,将仅加载您实际使用的模块,同时仍保留通过具名导出编写导入语句的便利性。

next.config.js
module.exports = {
  experimental: {
    optimizePackageImports: ['package-name'],
  },
}

默认已对以下库进行了优化:@mui/icons-material@mui/materialdate-fnslodashlodash-esreact-bootstrap@headlessui/react@heroicons/reactlucide-react