Barrel files optimization with modularizeImports
Unanswered
Dwarf Hotot posted this in #help-forum
Dwarf HototOP
Hello everyone,
we recently introduced Next.js in my company migrating our whole frontend and we’re all very happy with the result.
Since appetite comes with eating, we’d like to optimise our bundle taking advantage of the
1. Vercel never mentions that the
2. It seems that this configuration option is superseeded by
3. We have a huge application with many barrel files and many nested levels. We thought of building a tool that reads the module aliases and produce the configuration for the
Any input or ideas about other approaches is going to be very much appreciated.
Have the best day ever
we recently introduced Next.js in my company migrating our whole frontend and we’re all very happy with the result.
Since appetite comes with eating, we’d like to optimise our bundle taking advantage of the
modularizeImports configuration option. I created a sample repo (https://github.com/aheadintranet/barrel-files-optimizations) to proove that it can help us with the barrel files, but we have some questions:1. Vercel never mentions that the
modularizeImports configuration option is meant for local modules, but always talks about external libraries. Is it ok to use it this way? Are there any drawbacks?2. It seems that this configuration option is superseeded by
optimizePackageImports or it is going to be superseeded. Does it make sense to use modularizeImports or it's going to be deprecated and then removed soon?3. We have a huge application with many barrel files and many nested levels. We thought of building a tool that reads the module aliases and produce the configuration for the
modularizeImports option. A first purely Typescript approach works but it's rather slow for us. Would it make sense (or is it even possible) to write an SWC plugin in Rust to integrate in the build pipeline? Is it an idea that makes sense?Any input or ideas about other approaches is going to be very much appreciated.
Have the best day ever
1 Reply
Dwarf HototOP
Up?