Forums

Posting in these forums is disabled. These forums will be available for archive purposes. Please join the new forums at the links below:

  • yui-support - replaces the `YUI 3.x` and `YUI 3 Gallery` forums.
    We have created the following discussion categories within this group to aid discoverability for these most-used topics:
    • Charts for YUI Charts support.
    • DataTable for YUI DataTable support.
    • Gallery for YUI Gallery support, including support for published Gallery components as well as the Gallery process in general.
    • Tools for support of YUI’s suite of developer tools such as selleck, shifter, grover, yogi, etc.
    • Everything Else for questions that don’t fit one of the categories above, we’ve got you covered here.
  • yui-deprecated - replaces the `YUI 2.x` forum and the forums of other deprecated products (`YUI Doc`, `Builder`, `YUI PHP Loader`, etc.).
  [ 7 posts ]
New Topic | Post Reply | Print view
Previous topic | Next topic

Derek Gathright

YUI Developer

  • Username: drgath
  • Joined: Thu Apr 22, 2010 10:18 am
  • Posts: 7
  • Location: San Francisco, CA
  • Twitter: derek
  • GitHub: derek
  • Gists: derek
  • IRC: dgathright
  • YUI Developer
  • Offline
  • Profile
Tags:
  • gist
  • github
  • io
  • loader

AMD support within YUI

Post Posted: Thu Oct 20, 2011 3:20 pm
+0-
The core of today's Open Hours topic was AMD modules, and as I mentioned during the meeting, we'd love to hear from the community on a few things:
A) Is there interest in supporting the standard?
B) How would you like to use them? AMD modules loaded with YUI, or YUI as AMD modules?
C) Are there any approaches you've taken so far to integrate them within your YUI application?

Here's a gist of the notes I shared during the OH.
https://gist.github.com/02ebc7869df707fd3ab2

And here is the demo of RequireJS as a YUI module being used to include AMD modules. Yes, it's not an optimal solution, it just provides a playground for AMD+YUI.
http://derek.io/~/derek.github.com/sand ... index.html

Just something to note: We're really happy with YUI's loader and module system at this point. The reason for the discussion around AMD/RequireJS is because if standards are evolving within the greater JavaScript community, we're always interested in investigating those standards to see how they may (or may not) fit within the YUI project.

Juan Ignacio Dopazo

YUI Contributor

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

Re: AMD support within YUI

Post Posted: Thu Oct 20, 2011 6:09 pm
+0-
It's late and there's a lot to discuss, but I want to give leave a couple of thoughts.

YUI's module system is awesome. And it's more awesome considering that it was released a lot before the community realized it needed modules. It's more powerful than AMD/CJS2.0 with very little complexity added to the code, but with more to grasp conceptually. However, I think most developers will find AMD more intuitive.

Having said that, while I agree with whoever (I think it was Luke) said that there's no harm in having competing approaches, there are certain use cases in which AMD support of some kind would be great. Consider the following:

- I have a project in which I want to use a certain module, for example socket.io
- Managing socket.io's versions is a breeze with NPM
- Let's say socket.io uses AMD (I think it doesn't)

To avoid wrapping socket.io by hand with a YUI.add() call each time I update it, it would clearly be very useful to do YUI().use('socket.io') and have it just work.

I have started to write a short script that let's you do that, but I haven't finished it yet. I'll post it when it works.

jrburke

  • Joined: Thu Oct 20, 2011 4:21 pm
  • Posts: 2
  • Offline
  • Profile

Re: AMD support within YUI

Post Posted: Thu Oct 20, 2011 7:37 pm
+0-
jdopazo: if you mean having a script that can wrap CommonJS-like modules like socket.io into AMD, the requirejs optimizer has a converter:

node r.js -convert path/to/commonjs/dir output/dir

There is a little bit more info in the readme if you look for "-convert": https://github.com/jrburke/r.js

jrburke

  • Joined: Thu Oct 20, 2011 4:21 pm
  • Posts: 2
  • Offline
  • Profile
Tags:
  • gist
  • github
  • loader

Re: AMD support within YUI

Post Posted: Thu Oct 20, 2011 7:46 pm
+0-
I am interested to see if the YUI loader could load AMD modules and have them show up on the Y instance, something like indicated in this gist:

https://gist.github.com/1301798

I am willing to take a look at making some sort of adapter that could fit in with the YUI loader -- something that hopefully could use the YUI loader internals to set up the scripts, but set up the define() API so that it could accept an AMD module and bind it to the Y instance. Maybe just start with named AMD modules not anonymous ones, just to make it easier to start.

However, I am very new to the YUI code internals, any pointers would be helpful. I likely will not have time to do a proper deep dive on the code for a while, but if anyone has pointers I would likely go quicker.

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile
Tags:
  • loader

Re: AMD support within YUI

Post Posted: Thu Oct 20, 2011 8:43 pm
+0-
jrburke --

I would be happy to give you a hand with the Loader internals :)

Juan Ignacio Dopazo

YUI Contributor

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

Re: AMD support within YUI

Post Posted: Fri Oct 21, 2011 4:56 am
+0-
I thought about doing Y[moduleName] = module, but if the module is an object, don't you think it would be better to mix it into the Y instance? Would it be confusing if some modules appear as Y[moduleName] and others don't?

Juan Ignacio Dopazo

YUI Contributor

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

Re: AMD support within YUI

Post Posted: Sat Oct 22, 2011 4:30 pm
+0-
Getting this to work using the patterns configuration was surprisingly easy. There are some features needed from Loader, like regular expressions for patterns.

amd

Click here to see the revision history on this Gist.
  [ 7 posts ]
New Topic | Post Reply | Print view
Previous topic | Next topic
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