PDA

View Full Version : Sencha Build: Production version causes error, Testing version works fine



parky128
12 Mar 2012, 7:17 AM
I have a working testing build running, but when I create a production version, its build fine with no errors. However when I run in the browser I see this in the console:


Document was loaded from Application Cache with manifest http://localhost/pptouch/build/production/cache.manifest
Application Cache Checking event
Application Cache NoUpdate event
Error evaluating http://localhost/pptouch/build/production/app.js with message: ReferenceError: HistoryMarkerManagerInit is not defined index.html:71 (http://localhost/pptouch/build/production/index.html)


The 'HistoryMarkerManagerInit' the error refers is located in a script file which should be being loaded in before my app.js file is as its called in the launch function. I don't see this file being loaded in however when I look at the Network tab in Chrome debugging tools. This is no doubt down to my lack of understanding of what the production build is actually doing with my application!

Do I need to change something in my app.json config file before running the production build? I notice that in the config file is a section called 'appCache' and I see index.html is in a 'cache' array definition. Do I need my script references added in here too?

Thanks

mitchellsimoens
12 Mar 2012, 8:10 AM
Before you did the build, is the file for the HistoryMarkerManagerInit loaded via a <script> tag or is it required via Ext.require or the like?

parky128
12 Mar 2012, 8:30 AM
Well, the file is not included using a script tag or using a require.

I have some additional script files in my app.json file configured like so:


"js": [
{
"path": "sdk/sencha-touch.js"
},

{
"path": "Lib/markerwithlabel_packed.js",
"update": "delta"
},
{
"path": "Lib/markermanager-min.js",
"update": "delta"
},
{
"path": "Scripts/SBS.HistoryMarkerManager.js",
"update": "delta"
},
{
"path": "app.js",
"update": "delta"
}
]


The built testing version of the application loads these script files in the browser.

This wouldn't have anything to to with Ext.loader not being enabled in my application would it? Only, I generated my application structure using the Sencha command, and I see at the top of the app.js file that's created I have:


//<debug>


Ext.Loader.setPath({
'Ext': 'sdk/src'
});
//</debug>


I dont see:


Ext.Loader.setConfig({
enabled: true
});


which I do have in a version of my app.js which I wrote before the Sencha command tools were out for us to use.

mitchellsimoens
12 Mar 2012, 8:43 AM
Ext.Loader should not be used to load files dynamically in production. In your development the file is loaded via a require method?

parky128
12 Mar 2012, 9:18 AM
Im not using Ext.Loader anywhere in my code.

Before I answer your question, can you answer these for me...

When does the app.json file in the root of the directory (which gets generated from the sencha create command) get used? Should it only ever get used for build procedures via the sencha command?

Only when I look at my generated index file in the root of my working directory I have no script includes to my own script files so SBS.HistoryMarkerManager.js for example.

The only place I have a reference to this is in the js entries of the app.json file.

If I comment them out, I get undefined related script errors in the local version of my application. I thought this app.json file is only used for production purposes (according to the docs that is)

Thanks

Jacky Nguyen
12 Mar 2012, 10:50 PM
Im not using Ext.Loader anywhere in my code.

Before I answer your question, can you answer these for me...

When does the app.json file in the root of the directory (which gets generated from the sencha create command) get used? Should it only ever get used for build procedures via the sencha command?

Only when I look at my generated index file in the root of my working directory I have no script includes to my own script files so SBS.HistoryMarkerManager.js for example.

The only place I have a reference to this is in the js entries of the app.json file.

If I comment them out, I get undefined related script errors in the local version of my application. I thought this app.json file is only used for production purposes (according to the docs that is)

Thanks

app.json is used for development, as well as all the builds, so you're doing it correctly. It's the only one place to list out all assets to be loaded with your app.

First off, delete the 'archive' directory, and clear localStorage in your browser (as simple as running localStorage.clear() on the debugger's console).

Try 'sencha app build package' and run the package build on your browser to see if you have the same error.

Also, see if the files are actually loaded by do something like adding a "console.log('...')" (don't use alert(...)) at the end of each file, i.e: Lib/markerwithlabel_packed.js, Lib/markermanager-min.js, Scripts/SBS.HistoryMarkerManager.js. If you see the logs for all three, then it's more likely a run-time issue instead of loading issue.

Let me know the results, I'll follow up.

parky128
13 Mar 2012, 12:59 AM
Thanks Jacky,

I tried localStorage.clear() and it returns 'undefined' in the console. I can get to the localStorage object in the console (I am using Chrome by the way) and can see the clear function if I inspect the object.

Jacky Nguyen
13 Mar 2012, 11:47 PM
localStorage.clear() doesn't return anything so it's totally correct that you see "undefined" on the console. Have you tried the next 2 steps?

parky128
27 Mar 2012, 7:28 AM
Jacky,

Just following up on where we left off on this, I know it was some time ago!

Anyway, I have gone through the steps you have suggested and the package version of the build runs fine for me and I can see my console.log() outputs in the debugger.

The problems still remains for me in this production build where I get the error as stated in my first post on this thread.

echobloom
21 Nov 2012, 9:25 AM
I've got this exact same problem - any resolution on this?

diesalher
18 Feb 2013, 3:33 AM
Same problem here żAny idea?