Next.js · Senior · Question 16 of 75
What does optimizePackageImports do?
- ✓Correct answer: Loads only the used modules from libraries with barrel files
- 2Compresses all npm packages into one file at build time
- 3Automatically updates dependencies to the latest versions
Explanation
Importing import { Icon } from 'big-icon-lib' through a barrel file can pull in hundreds of modules and slow down the build and the dev server. The option rewrites imports to the specific modules. For some popular libraries Next.js does this automatically.