How to conditionally include a module based on environment

In my app.module.ts I’d like to conditionally include a module e.g.
imports: [
isDevMode() ? StoreDevtoolsModule.instrument() : []

However this causes NGC to fail when building for prod.
Is there a recommended way to do this kind of thing?