-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add default modularizeImports that breaks up @mui/icons-material, @mui/material, date-fns, lodash, lodash-es, ramda, react-bootstrap #50900
Changes from all commits
3130752
cbf28e2
818017d
4c37fb5
d55ac66
e3c4035
194fa9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/[email protected]/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': { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: what do you think about including 'lodash/fp': {
transform: 'lodash/fp/{{member}}',
}, |
||
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}}', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change results in the following error Module not found: Can't resolve 'react-bootstrap/useAccordionButton'
3 | import { Inter } from 'next/font/google'
4 | import styles from '@/styles/Home.module.css'
> 5 | import { useAccordionButton } from 'react-bootstrap'
6 |
7 | const inter = Inter({ subsets: ['latin'] })
8 | There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because some hooks do not have independent files, the above problems are caused. If someone encounters the above issue when using react-bootstrap and receives the error message const nextConfig = {
webpack: config => {
let modularizeImports = null
config.module.rules.some(rule => (
rule.oneOf?.some(oneOf => {
modularizeImports = oneOf?.use?.options?.nextConfig?.modularizeImports
return modularizeImports
})
))
if (modularizeImports?.['react-bootstrap'])
delete modularizeImports['react-bootstrap']
return config
}
} |
||
}, | ||
} | ||
|
||
return result | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work. It was reported in #51872. I have open #51953 to fix this.