Twitter Call us on +44 (0)1256 486557

Sencha CMD 5 broken Ext.Msg.alert – Uncaught TypeError: undefined is not a function

Note: This article applies to Sencha Cmd 5 only. This was not an issue when the app was built with Sencha Cmd 4.

My Sencha Touch 2.3.1 project was building. It worked in development. Now all I needed to do was publish! I had previously taken the step to upgrade the app using Sencha CMD from 4 to 5.

After running sencha app build (defaults to production) the app successfully built from the command line. I was ready to deploy….or was I! On first inspection the app appeared to work ok.

On testing the app, I noticed an error with Ext.Msg.alert('Title', 'This is a message');.

The MessageBox was not displaying correctly as seen here:

Broken Ext.Msg.alert

Broken Ext.Msg.alert

The precise error from web developer tools can be seen in this screenshot here:

Ext.Msg.alert display issue

Ext.Msg.alert display issue

I have seen errors like this numerous times before so I was confident of fixing. I could not have been more wrong! After 4 hours of debugging refusing to give up on the production build I finally realised the issue was not with my code but with the Sencha build process. I tracked down the following line in ./sencha/app/production.defaults.properties

build.optimize=${build.optimize.enable}

By commenting this line out and essentially disabling the full class system optimizer, I re-built and the issue was gone!

I hope this helps someone else with the same problem. It is worth noting that this was not the only issue we encountered with the broken build, and if we ran sencha app build testing or any other for that matter the code ran just fine. It was only an issue with the production build which is why an understanding of the Sencha build process was required. More can be found here on the Sencha build process for your info:

Sencha CMD Enterprise Workflow