For some reason, Sencha Cmd fails when it parses app.js with custom code. Below, is a snippet from an application I'm deploying to testing (unminified JavaScript but in a single file) or to production (minified JavaScript).
The browser throws the following JavaScript exceptions from the deployed folder (with all-classes.js):
(note: the folder with all js source code runs fine)
GET http://localhost/App/App/model/app/CheckTreeNode.js?_dc=1396967410158 404 (Not Found) all-classes.js:10841
GET http://localhost/App/App/store/app/UserPreferenceNodes.js?_dc=1396967410159 404 (Not Found) all-classes.js:10841
GET http://localhost/App/app/controller/ViewportAdmin.js?_dc=1396967410177 404 (Not Found) all-classes.js:10841
...
Uncaught Error: [Ext.Loader] Failed loading 'App/model/app/CheckTreeNode.js', please verify that the file exists all-classes.js:11259
Uncaught Error: [Ext.Loader] Failed loading 'App/store/app/UserPreferenceNodes.js', please verify that the file exists all-classes.js:11259
Uncaught Error: [Ext.Loader] Failed loading 'app/controller/ViewportAdmin.js', please verify that the file exists
I tried fixing things by adding a "requires" config in my Ext.application class, but that didn't help. How can I force these files to be seen by Sencha Cmd? Sencha Touch has a solution by allowing you to add files to "app.json". Perhaps there is a similar solution for ExtJS applications that I'm unaware of?
If there are more elegant solutions, I'm open to them. I needed the user preferences in the constructor of a bunch of my classes, so this was the only place I could get it to load and be ready when those are called. If there is a different way to load data that can be available when building classes within MVC, I'm fine with a different solution for that. As for having two viewports, this is what I found to work, so that's what ViewportAdmin is. Just a second viewport.
app.js source code:
Ext.application({
name: 'App',
extend: 'App.Application',
requires: [
'App.store.app.UserPreferences',
'App.view.ViewportAdmin'
],
autoCreateViewport: false,
launch: function () {
Ext.StoreManager.lookup('App.store.app.UserPreferences').on('load', function () {
if (window.location.href.indexOf('/App/index.aspx?admin=true') > -1) {
Ext.create('App.view.ViewportAdmin');
}
else if (window.location.href.indexOf('/App/index.aspx') > -1) {
Ext.create('App.view.Viewport');
}
});
}
});
The problem wasn't due to what I suspected. After deploying the app to testing (ran command "sencha app build testing", I put a breakpoint on the two lines of code below. It turns out that the controller that it errored on had the store which was not being used. It failed because of that. The CheckTreeNodes.js was the model being used in that store. I just removed it from the stores list to resolve it.
code in all-classes.js (generated from YUI compressor I think):
script.src = url;
(Loader.documentHead || document.getElementsByTagName('head')[0]).appendChild(script);
I looked at the call stack in Google Chrome and found that the anonymous function call (in the call stack) was showing the list of stores from the ViewportAdmin controller.
Related
We have an existing ExtJS app that works perfectly when not minified or merged into a single bundle file.
After we ran sencha app build command and created a app-all.js file, some screens are not working as before and is giving Error:
Cannot read property 'xxxxx' of undefined.
A sample snippets that gives the above error is:
function(b){
var a=b, c=a.something, d=c.somethingElse;
}
here, it says:
cannot read property something of undefined.
Why does the behavior of the code change after the build?
The issue in my case was that there were some backup files of which had different name but the content was older version of the actual file to be loaded. For example, when application is not minified, say the file getting loaded is root.some.path.OneSampleFile.js. When minified, another File OneSampleFileBackup.js was overwriting OneSampleFile as both the files said
Ext.Define('root.some.path.OneSampleFile')
Trying to figure out if there is any easier way to locate files that have duplicate declarations or to only include files whose ext define path and location matches, in the app-all.js build.
I am using Karma with Mocha and karma-fixture. If I go into debug when I run tests, I can see the file is loaded in the server. If I changed the config included:true, then I can see it's loaded on the console. The extension is changed to .js (rather than .json) and if I view source on the file (in browser window) the json is wrapped in a function -- so it seems like everything is happening as described in the documentation. However, I get an error that the file cannot be found. I have included the relevant configs and errors below.
Update 1
I was able to load the fixture with require -- which I'm using anyway to manage and load dependencies. The data is assigned to an array like this: __json__['test/fixtures/json-data/querybrowser']. I would still be interested in knowing why I can't use the fixture.load() function. I feel like I am missing a simple detail here.
Thank you!
The configuration:
The file is located here, pathed from root of my project: \test\fixtures\json-data\querybrowser.json
Karma
files: [{pattern: 'test/fixtures/{,*/}*', watched: true, included: false, served: true}]
TEST spec
fixture.setBase('base/test/fixtures/json-data');
querybrowser_json = fixture.load('querybrowser.json');
The Error
Chrome 48.0.2564 (Windows 7 0.0.0) Query Browser Function Tests "before all" hook FAILED
ReferenceError: Cannot find fixture 'base/test/fixtures/json-data/querybrowser.js'
at Fixture._throwNoFixture (////node_modules/karma-fixture/lib/fixture.js:141:13)
Have you:
Made sure that you're including the JSON files in both your files array and your preprocessors array inside your karma config?
Made sure that you have transformPath property defined in jsonFixturesPreprocessor as per https://github.com/billtrik/karma-fixture/issues/10?
I had the same issue as you but doing these things fixed it for me.
My first Phonegap App. Everything working well except for plugins. I'm trying to install the cordova-plugin-purchase Plugin.
https://github.com/j3k0/cordova-plugin-purchase
I've followed the instructions. And when I run "phonegap plugins" in the console it shows the plugin as being installed.
According to the documentation, there is suppose to be a "store" object that I can reference. I set up the following code to test if it's working:
try {
store.register({
id: "my.reverse.item.example",
alias: "example name",
type: store.CONSUMABLE
});
} catch(err) {
alert(err);
}
On my real project, I have the real info in when registering the product, but I can't even get that far. In my TryCatch it returns the following alert:
"Can't find variable: store".
So it seems that the plugin isn't even installed correct. I'm not to phonegap plugins, so there's probably something very basic that I'm missing. Do I have to include a link to the plugin JS in my index.html file?
I ended up figuring out the problem. It seems to be that I didn't include the cordova.js file in my index.html. I don't see why I needed to do that since I've read over and over that you don't need to manually add the cordova files to your html files.
So the plugin works now and I can receive the store data that I setup using the cordova-plugin-purchase plugin tutorials.
Another thing to note once you actually have the plugin installed correctly:
The Bundle Identifier in Xcode needs to match the bundle ID for the In App purchases you are trying to connect to.
I am developing an app using BackboneJS and requireJS, today suddenly I started seeing an error in chrome console.
Uncaught Error: Backbone.history has already been started
I checked if I've accidentally started the backbone history twice but that was not the case.
In firefox their is no error.
While debugging I noticed that the main file mentioned in the data-main of the script tag is being called twice.
<script data-main="/ui/main.js" src="/ui/libs/require.js"></script>
Updating chrome to the latest version also didn't help.
One more clue that this might be a chrome update issue is while using one other app Productive I realised that its also made using backbone and require and in the console its throwing the same error
Uncaught Error: Backbone.history has already been started
Due to double calling of the main file the app is initialized twice and all the events are being triggered twice because of duplicate Views.
I'm not sure how to solve this. How can I avoid starting my app twice in case the main file is called multiple times. What can be a better approach to handle this kind of situation.
I'm using
Chrome (Version 44.0.2403.157 (64-bit)) on Mac OSX 10.10.4
require.js 2.1.18
Backbone.js 1.2.1
[EDIT] Adding sample : http://vipul261.github.io/test.html
you can check the main file named main.js
Main file:
(function () {
'use strict';
requirejs([
'domReady!'
], function (document, App) {
alert('Hello');
});
}());
I forked Brackets, because I'm planning to make a code editor fully integrated if Steam. To do so, using Javascript, I add a git submodule on the thirdparty folder to use the greenworks repo (a solution to make Steamworks work with Javascript). I loaded this module on brackets.js, like so:
// Load greenworks module
var greenworks = require("thirdparty/greenworks/greenworks");
But when I call it, either on my extension, or even on console, it says:
[Extension] failed to load C:/Program Files (x86)/Brackets/dev/src/extensions/dev/greenworks - Error: Module name "/thirdparty/greenworks/greenworks" has not been loaded yet for context: _
or
Error: Module name "/thirdparty/greenworks/greenworks" has not been loaded yet for context: _
Besides brackets.js, where else should I call greenworks module before I use it (on a extension, or on the console for testing purposes)?