NEXTJS_MISSING_MODULARIZE_IMPORTS
modularizeImports can improve dev compilation speed for packages that use barrel files.Conformance is available on Enterprise plans
modularizeImports
is a feature of Next 13 that can reduce dev compilation times
when importing packages that are exported as barrel files. Barrel files are
convenient ways to export code from a package from a single file to make it
straightforward to import any of the code from the package. However, since they export a
lot of code from the same file, importing these packages can cause tools to do
a lot of additional work analyzing files that are unused in the application.
To fix this, you can add a modularizeImports
config to next.config.js
for
the package that uses barrel files. For example:
modularizeImports: {
lodash: {
transform: 'lodash/{{member}}';
}
}
The exact format of the transform may differ by package, so double check how the package uses barrel files first.
See the Next.js docs for more information.
You can also specify required modularizeImports
config for your own packages.
In your conformance.config.jsonc
file, add:
NEXTJS_MISSING_MODULARIZE_IMPORTS: {
requiredModularizeImports: [
{
moduleDependency: 'your-package-name',
requiredConfig: {
transform: 'your-package-name/{{member}}',
},
},
];
}
This will require that any workspace in your monorepo that uses the
your-package-name
package must use the provided modularizeImports
config
in their next.config.js
file.
See Customizing Conformance for more information.
Was this helpful?