[ 7 posts ]

Daniel Dekel

  • Username: dekelraviv
  • Joined: Wed Sep 08, 2010 7:02 am
  • Posts: 9
  • Location: London, UK
  • Offline
  • Profile

YUI Loader problem when migrating from 3.3 to 3.4

Post Posted: Fri Aug 26, 2011 8:11 am
+0-
Hi, I have a complex client application based on YUI. This application loads classes on demand without the possibility of knowing in advance what classes are going to be loaded nor the paths of those classes.

A short description of the code before you can see the example is that I load a BaseApp class (extending Y.Base), that class loads by configuration some other classes that are attached to the BaseApp as plugins. The problem is that after I load the classes on demand, the classes also have dependencies to YUI modules as well as local modules.

The problem is that when the second class is loaded, the dependencies are not working. If you switch between the first and the second the same result will happen, meaning that is not an issue of a problem in one of the classes.

The code is here: https://docs.google.com/document/pub?id=1J5VWSLPiNaBRIb1eP-LH_1GoGrYTNZdIqAzYahAIDSs

If I switch from yui 3.3 it will work but in YUI3.4 I will get the following result in mu console:

initializer: BaseApp base_app.js (line 11)
Loaded: pluginModule - PluginOne PluginOne.js (line 1)
Loaded: pluginModule - PluginTwo PluginTwo.js (line 1)
Loaded: WidgetOne widget_one.js (line 1)
yui: NOT loaded: WidgetTwo yui-min.js (line 11)

Any ideas?

bdicasa

  • Joined: Sun Sep 04, 2011 10:11 am
  • Posts: 5
  • Offline
  • Profile

Re: YUI Loader problem when migrating from 3.3 to 3.4

Post Posted: Sun Sep 04, 2011 10:19 am
+0-
I'm having the exact same problem. My dependencies are loaded correctly using 3.3.0 - however if I upgrade to 3.4.0, my dependencies are not being resolved properly before the module is loaded.

For example, I'm trying to extend the controller module:

Code:
YUI.add('base-controller', function(Y) {
    Y.Base.create('baseController', Y.Controller, [], {
        // Y.Base throws undefined exception...
    });
}, '1.0.0', {
    requires: ["controller"]
});


We're you able to find anything out?

Juan Ignacio Dopazo

YUI Contributor

  • Username: jdopazo
  • Joined: Fri Oct 02, 2009 5:39 am
  • Posts: 638
  • Location: Buenos Aires, Argentina
  • Twitter: juandopazo
  • GitHub: juandopazo
  • Gists: juandopazo
  • Offline
  • Profile
Tags:

Re: YUI Loader problem when migrating from 3.3 to 3.4

Post Posted: Sun Sep 04, 2011 2:19 pm
+0-
IIRC, for custom modules to load requirements from the "requires" attribute in the module file (not in the YUI configuration object), you must declare them inside a group, not directly into the modules property.
Code:
YUI_config = {
  groups: {
    myApp: {
       base: 'path/to/my/app/'
       modules: {}
    }
  }
};


Side note: using <DOCTYPE html> means you're not using XML, so you don't need to add a <?xml version="1.0"> tag before the doctype in that case.

Daniel Dekel

  • Username: dekelraviv
  • Joined: Wed Sep 08, 2010 7:02 am
  • Posts: 9
  • Location: London, UK
  • Offline
  • Profile
Tags:

Re: YUI Loader problem when migrating from 3.3 to 3.4

Post Posted: Tue Sep 20, 2011 2:38 am
+0-
Hi, thank you for the answer and sorry for the late response.
I've tried to use the groups and it looks like it is willing to load he modules declared in the requires of the actual module (YUI.add) but it fails to load them.

There is a console warning saying "yui: NOT loaded: base-base"

But if I add the same requires to the config it will load the "base-base" module.

My config looks like this:
Code:
config = {
    base: "yui/3.4.0/",
    groups: {
        myApp : {
            base: "yui/3.4.0/",
            modules: {
                BaseApp : {
                    fullpath: "base_app.js"
                }
            }
        }
    }
};


I've checked in firebug if it is trying to load the files because it might be a path problem, but it doesn't even try to load the JS files.

Any ideas?


Last edited by dekelraviv on Tue Sep 20, 2011 3:32 am, edited 1 time in total.

Daniel Dekel

  • Username: dekelraviv
  • Joined: Wed Sep 08, 2010 7:02 am
  • Posts: 9
  • Location: London, UK
  • Offline
  • Profile

Re: YUI Loader problem when migrating from 3.3 to 3.4

Post Posted: Tue Sep 20, 2011 3:31 am
+0-
By the way, thank you Juan for the side note!
(Soy un ex porteƱo)

Daniel Dekel

  • Username: dekelraviv
  • Joined: Wed Sep 08, 2010 7:02 am
  • Posts: 9
  • Location: London, UK
  • Offline
  • Profile

Re: YUI Loader problem when migrating from 3.3 to 3.4

Post Posted: Thu Sep 29, 2011 12:12 am
+0-
Just for the record, after long discussions we reached to the conclusion that is not possible to load modules through the requires of the add method. All the dynamic loading must be declared in the configuration of the YUI().use().

It is also not working if you declare the modules inside a group of the configuration as many mentioned in other conversation.

For me is a big limitation since many times I don't know in advance the requirements of a module but is the module itself that knows in the file its requirements.

As I understood, it is done by design and is not a bug.

Some suggestions:

1. Add this limitation to the documentation of YUI because at the moment is an obscure subject.
2. Please add this feature. I understand that this makes the loader slow, but if I choose to use that option, is because I need it. So as long as is documented that it will be slower because it has to load the files in two iterations, is OK.

Nick Husher

YUI Contributor

  • Offline
  • Profile

Re: YUI Loader problem when migrating from 3.3 to 3.4

Post Posted: Thu Sep 29, 2011 5:32 am
+0-
Quote:
Just for the record, after long discussions we reached to the conclusion that is not possible to load modules through the requires of the add method. All the dynamic loading must be declared in the configuration of the YUI().use().


That's not strictly true. Requirements for modules are added if the module is included in the markup at page load, or is executed before a Y.Loader request. But you are right in the general use case; module dependencies are not recalculated as the modules are loading.

This issue is covered by this ticket, and should be fixed for 3.5.0.
  [ 7 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum