Milton
Milton

Reputation: 968

Sencha AlternateClassName do not work in compiled version

I'm working in a Sencha application.
I've created a couple of Utilities classes as singleton components (helpers, services, etc).
I'm using alternateClassName to have a shorter name for those classes.
It works perfect, but stop working after compiling for production.

I don't know why, and need help to get this working!

Looks to the following example:
I've created a demo application using sencha cmd for simplicity. The application is "Demo".
The whole application is as default, but I've added a util folder inside app, with a single file Helper.js. This is the code:

Ext.define('Demo.util.Helper', {
    singleton: true,
    alternateClassName: 'Helper',

    test: function () {
        alert('It works !');
    }
});

Then, I just need to update app.js to require this new file, and update the launch function to call test method after add the main view. So here is the code to use in app.js:

requires: [
    'Ext.MessageBox',
    'Demo.util.Helper'
],

The launch function:

launch: function () {
    // Destroy the #appLoadingIndicator element
    Ext.fly('appLoadingIndicator').destroy();

    // Initialize the main view
    Ext.Viewport.add(Ext.create('Demo.view.Main'));

    Helper.test();
},

Now, if I try the example, after load the app, an alert msg is shown successfully.

Success

But after compile it using sencha cmd

sencha app build production

I get this error:

Fail

I know the problem is with alternate class name, because if I use the full name (instead of alternate class name), it works anyway. But I want to use alternate class name, otherwise it doesn't make any sense.

Any idea on what's wrong with compiled version ?

TIA! Milton

Upvotes: 0

Views: 384

Answers (1)

Milton
Milton

Reputation: 968

After some time, we realized that Sencha has a bug when compiles singleton classes for production (works on testing also).

The solution was to remove the singleton flag, and create application variable for all of the singleton classes, in the launch method.

For example:

Demo.Helper = Ext.create('Helper');

Hope this help!

UPDATE

Last version of Sencha Cmd is full of freaking bugs! I found a lot of other issues after fixing this ones, and finally, I found this link http://www.sencha.com/forum/showthread.php?288972-MyAppName.app-not-working-on-build-production&p=1064635

Upvotes: 0

Related Questions