Leveraging Tree-Shaking
Tree-shaking is a build step in which unused module exports are removed from the final bundle. To enable this behaviour refer to ng build documentation.
In order for the tree shaking to work effectively with Angular InstantSearch, refrain from importing NgAisModule
. Instead import the modules you need individually.
Don’t do this:
import { NgAisModule } from 'angular-instantsearch'; @NgModule({ imports: [NgAisModule.forRoot()], }) export class AppModule {}
Do this instead:
import { NgAisInstantSearchModule, NgAisHitsModule, NgAisSearchBoxModule, } from 'angular-instantsearch'; @NgModule({ imports: [ NgAisInstantSearchModule.forRoot(), NgAisHitsModule, NgAisSearchBoxModule, ], }) export class AppModule {}