Unverified Commit 0a4b6ef8 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Add default modularizeImports that breaks up lucide-react, mui/icons-material,…

Add default modularizeImports that breaks up lucide-react, mui/icons-material, lodash, react-bootstrap (#50900)

## What?

Adds a default modularizeImports that ensures `lucide-react`, `@mui/icons-material`, `lodash`, and `react-bootstrap` do not cause a massive amount of modules to be compiled in development.
For example `@mui/icons-material` re-exports 10600 (10K+) modules from a single file. Even though it does not affect production bundle size it does affect build time, especially in development, and even more so when your filesystem is slow (e.g. what we're seeing on Windows). 

Related issue: #48748 (not closing)
Co-authored-by: 's avatarShu Ding <3676859+shuding@users.noreply.github.com>
parent fb79c116
...@@ -673,6 +673,40 @@ function assignDefaults( ...@@ -673,6 +673,40 @@ function assignDefaults(
} }
} }
const userProvidedModularizeImports = result.modularizeImports
// Unfortunately these packages end up re-exporting 10600 modules, for example: https://unpkg.com/browse/@mui/icons-material@5.11.16/esm/index.js.
// Leveraging modularizeImports tremendously reduces compile times for these.
result.modularizeImports = {
...(userProvidedModularizeImports || {}),
// This is intentionally added after the user-provided modularizeImports config.
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}',
},
'@mui/material': {
transform: '@mui/material/{{member}}',
},
'date-fns': {
transform: 'date-fns/{{member}}',
},
lodash: {
transform: 'lodash/{{member}}',
},
'lodash-es': {
transform: 'lodash-es/{{member}}',
},
// TODO: Enable this once we have a way to remove the "-icon" suffix from the import path.
// Related discussion: https://github.com/vercel/next.js/pull/50900#discussion_r1239656782
// 'lucide-react': {
// transform: 'lucide-react/dist/esm/icons/{{ kebabCase member }}',
// },
ramda: {
transform: 'ramda/es/{{member}}',
},
'react-bootstrap': {
transform: 'react-bootstrap/{{member}}',
},
}
return result return result
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment