false
Used to enable the lazy compilation (i.e. compile on demand). When this config is enabled, Modern.js will compile entrypoints and dynamic imports only when they are used. It will improve the compilation startup time of the project.
Lazy compilation only takes effect in the development.
Lazy compile async modules introduced by dynamic import:
When imports
option is enabled, all async modules will only be compiled when requested. If your project is a single-page application, and routing is split through dynamic import, there will be a significant effect of speeding up compilation.
In addition to lazy compilation for async modules, you can also choose to lazily compile both entries and async modules at the same time.
The above config can also be simplified to:
When entries
option is enabled, all pages will not be compiled when the compilation is started, and the page will be compiled only when you visit it.
When using lazy compilation for entries, there are some considerations:
When you enable lazy compilation, in order to ensure the compilation results, Modern.js will disable split chunks in the development. This will not affect the build results in the production, but will cause a difference between the build results of the development and production.
Lazy Compilation relies on the local development server of webpack. When you proxy a domain name to localhost, Lazy Compilation will not work properly. Therefore, if you need to develop with proxy, please disable Lazy Compilation.
Considering that Lazy Compilation is still an experimental feature of webpack, you may encounter some potential issues while using it, such as changes in the behavior of compiled artifacts or compilation errors.
When you encounter these issues, you can refer to webpack Issues to find solutions or disable the lazyCompilation
configuration option.