@ngrx/state does not work in production build

I have found similar problems on search (issues with third parties libraries on production build).

@ngrx/state Works fine in dev build.

But when in production mode, the module seems not to be there (I got a type error because the reducer is undefined).

I guess it’s a tree-shaking issue, but have no clue how to fix it.

My ionic info:

cli packages: (/home/guilherme/.nvm/versions/node/v8.0.0/lib/node_modules)

@ionic/cli-utils  : 1.12.0
ionic (Ionic CLI) : 3.12.0

global packages:

cordova (Cordova CLI) : 7.0.1 

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : android 6.2.3 browser 4.1.0
Ionic Framework    : ionic-angular 3.6.1


Node : v8.0.0
npm  : 5.0.3 
OS   : Linux 4.4


backend : pro

What is the command used to build?
What is the exact error you are getting?

I got the error with the --prod flag. ionic cordova build android --prod. The same thing happens in browser build.

ionic cordova build android --release works fine, but then build is too big.

Seems like the reducer function doesn’t exists at all in the --prod mode.

When I do this.store.dispatch nothings happens. No errors messages.

Then, when I select the appstate (this.store.select) I get a type error, because the state is undefined (which is defined by the reducer function)

I get no lint errors at build time. This errors just happens at runtime, and I see this while inspecting in Chrome.

Dev build works fine too.

Seems like a tree-shake bug, how can I disable this? setting “ionic_manual_treeshaking” to false doesn’t work.

OK, I just found the problem.

It’s a ngc bug.

this wont work (app.module.ts) :

imports: [


This is the right way to go:

imports: [


Very odd!!