optimizePackageImports
一部のパッケージは何百、何千ものモジュールをエクスポートすることがあり、それが開発環境と本番環境でのパフォーマンス問題の原因となることがあります。
パッケージをexperimental.optimizePackageImports
に追加すると、実際に使用しているモジュールのみがロードされます。その一方で、多くの名前付きエクスポートを持つインポートステートメントを記述する利便性は維持されます。
next.config.js
module.exports = {
experimental: {
optimizePackageImports: ['package-name'],
},
}
以下のライブラリはデフォルトで最適化されています。
lucide-react
date-fns
lodash-es
ramda
antd
react-bootstrap
ahooks
@ant-design/icons
@headlessui/react
@headlessui-float/react
@heroicons/react/20/solid
@heroicons/react/24/solid
@heroicons/react/24/outline
@visx/visx
@tremor/react
rxjs
@mui/material
@mui/icons-material
recharts
react-use
@material-ui/core
@material-ui/icons
@tabler/icons-react
mui-core
react-icons/*
お役に立ちましたか?