PDA

View Full Version : JSBulder File order for extjs 4.1



varunach
20 Feb 2013, 11:56 AM
Hi,

Is the order in which I declare my files in the jsb2 file important? For example :


filesInclude : [{
text : "file1.js",
path : "path/to/file"
}, {
text : "file2.js"
path : "path/to/file"
}]

Here file1 has a dependency on file2, but if I declare the files as above, will the single js generated by JSBuilder work? I'm using Ext JS 4.1.1

vadimv
20 Feb 2013, 12:34 PM
Depends on what is within those files. The basic rule is to load first the code which is used later in other files. To give you an example: if the order would be like you posted and if you instantiate a class in file1 which is defined in file2 then you will get an undefined error, or sth like this.

varunach
20 Feb 2013, 12:54 PM
So say if after creating my app-all.js file using JSBuilder I get a file like:



Ext.define('MyClass1, {
requires : ['MyClass2'],
initComponent : function() {
var comp = Ext.create('MyClass2');
}
});
Ext.define('MyClass2', {
initComponent : function() {
//some code to create component
}
});
Ext.application({
name : 'App',
// other config,
launch : function() {
this.view = Ext.create('MyClass1');
}
});


This will create an error?

varunach
20 Feb 2013, 12:58 PM
Also, I get an error like

[ERROR] : 8641:4:syntax error

The debug file is created but the compressed one isn't. So how do I find the file which caused the error?

varunach
20 Feb 2013, 1:03 PM
Got the problem.. I had used a json object of the form {class : 'somevalue'}. class is a reserved keyword, so YUI compressor was complaining. If i change it to "class" it compiles successfully

varunach
20 Feb 2013, 1:42 PM
Yeah.. The file order is important.