I am using CMD and extjs. In my Main.js i have something like
Ext.define('Abc.view.main.Main', {
extend: 'Ext.panel.Panel',
xtype: 'app-main',
header:{
height: 25,
titleAlign: 'center',
title: 'new tile,
padding: '0 0 0 10'
},
requires: [
'Abc.view.main.MainController',
'Abc.view.main.Component'
],
If you see requires, i am requiring some classes. If i remove all the classes in requires and leave it like
requires: []
all the pages are loaded properly only. So whats the benefit i am getting by adding files in requires.
First, your application (
Application.js) has a list of requiredviewsandstoresandcontrollers. If your controller and component are in these "global" lists, they are already loaded when yourrequireslist is evaluated, so you don't see a difference at all. If you reuse the component in other projects, and you forget to add it to theApplication.js, you may see a difference.If they are not already loaded when they are needed, three things can happen:
xtypeis not yet registered withComponentManager, so if you instantiate byxtype, this will fail ("could not resolve dependency").requireslist at once.If you instantiate using variables, Sencha Cmd is completely unable to add the required files to the dependency tree, and they may be missing in the built file. Example:
Because the
requireslist is also used by Sencha Cmd to resolve the dependency tree and make a correct partial order of the component definitions in the built js file.