optimizePackageImports
一部のパッケージは数百または数千のモジュールをエクスポートする可能性があり、開発環境や本番環境でパフォーマンスの問題を引き起こすことがあります。
experimental.optimizePackageImportsにパッケージを追加すると、実際に使用しているモジュールのみがロードされ、多くの名前付きエクスポートを含むインポート文を記述する便利さはそのまま維持されます。
module.exports = {
experimental: {
optimizePackageImports: ['package-name'],
},
}以下のライブラリはデフォルトで最適化されています:
lucide-reactdate-fnslodash-esramdaantdreact-bootstrapahooks@ant-design/icons@headlessui/react@headlessui-float/react@heroicons/react/20/solid@heroicons/react/24/solid@heroicons/react/24/outline@visx/visx@tremor/reactrxjs@mui/material@mui/icons-materialrechartsreact-use@material-ui/core@material-ui/icons@tabler/icons-reactmui-corereact-icons/*