-
2 Oct 2012 10:26 AM #1
Answered: production build issues with Sencha Touch 2
Answered: production build issues with Sencha Touch 2
Hello,
I currently have a Sencha Touch 2 application that has been written and tested in a local IIS environment.
When I deploy it to an IIS server (our DEV environment) the application takes a long time to load up all the library files that are required.
I then used the Sencha SDK tools to create a 'production' build.
In order to test the build I have deployed it again to my local IIS environment but get the following errors in the application
error.jpg
By tracing back through the code I can see that the errors occurs when I call setHtml('') on a list object.
What else can I do to further debug the issue? The problem only occurs after I do the build.
Thanks
-
Best Answer Posted by shepsii
I don't know how much this helps.... but I have previously discovered that code in the global scope executes in a different order after minimization.
The reason for this is that Sencha Command builds the single app.js file so that the Ext.Application call is right at the bottom. Usually it would be the first code executed; after a production build it's essentially the last (in the global scope at least).
My bet is that your ID strings are therefore in the minimized file being set too late, and you're trying to reference them before they're set perhaps? So no element is found when you try to get an element with a null ID.
-
2 Oct 2012 3:19 PM #2
Your list object doesn't exist (yet). You may want to call setHtml() after the initlialize event of the list.
-
3 Oct 2012 10:01 AM #3
Is there a way to debug which setHtml call is causing the issue.
It is not apparent which call could be the issue.- I call it on the list.load event handler but the load does not occur until after view is initialized (which is created in the application.launch)
- I have a call to setHtml in the keyUp event of a search box (which is created as part of the view definition)
Additionally if the object not being set was the cause of the problem would I see the error before I use the 'production' build of the application?
Thanks
-
3 Oct 2012 12:00 PM #4
After a bit more investigation it looks like alot of my components are not being assigned ID's.
At the very top of my app.js file I have global constants like the following
Those constants are what I use to ID my components and then retrieve them afterwards.Code://global constants var NEW_SEARCH_BTN_ID = 'newSearchBtn'; var SEARCH_HOME_INPUT_ID = 'searchQueryBox'; var SEARCH_PREVIEW_LIST_ID = 'searchPreviews'; var SUBMIT_SEARCH_BTM_ID = 'submitSearchBtn';
Could the build process affect the scope of these ID's since they are defined in app.js?
I ask this because in the browser console if I enter in one of the constants it comes up as undefined.
thanks
-
5 Oct 2012 11:36 AM #5
bump
Can anyone elaborate on what happens to global variables during the production build process?
thanks
-
8 Oct 2012 12:28 AM #6
-
8 Oct 2012 12:33 AM #7
I don't know how much this helps.... but I have previously discovered that code in the global scope executes in a different order after minimization.
The reason for this is that Sencha Command builds the single app.js file so that the Ext.Application call is right at the bottom. Usually it would be the first code executed; after a production build it's essentially the last (in the global scope at least).
My bet is that your ID strings are therefore in the minimized file being set too late, and you're trying to reference them before they're set perhaps? So no element is found when you try to get an element with a null ID.
-
9 Oct 2012 2:15 PM #8
shepsii,
That was exactly what was happening - the way the build was happening the constants were not even being loaded.
Rather than using a singleton class as was suggested (it would have require a major refactoring effort to change how the constants were being called) I created a constants.js file that I included from the index.html side so that those variables are not minified as part of the build process.
I can get the application to load properly in the production build format now
thanks!


Reply With Quote