Company
Date Published
Author
Shu Ding
Word count
1222
Language
English
Hacker News points
2

Summary

We've optimized package imports in Next.js, improving both local development performance and production cold starts for users of large icon or component libraries. By analyzing entry files on the fly and automatically mapping all imports, we've seen 40% faster cold boots and 28% faster builds. This change was needed due to the hidden cost of importing thousands of unneeded modules from barrel files, which can slow down both local development and production performance. Our new solution, `optimizePackageImports`, is more efficient than tree-shaking and handles recursive barrel files, resulting in improved performance improvements for users.