Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Help adding AMD support to a library
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
James Burke  
View profile  
 More options Feb 22 2012, 7:56 pm
From: James Burke <jrbu...@gmail.com>
Date: Wed, 22 Feb 2012 16:56:25 -0800
Local: Wed, Feb 22 2012 7:56 pm
Subject: Re: [requirejs] Help adding AMD support to a library

On Wed, Feb 22, 2012 at 2:13 AM, olivernn <oliver.nightinga...@gmail.com> wrote:
> I have an open source library, http://davisjs.com, that I want to add
> optional AMD support to and am wandering about the best way to go
> about this.

Here are some examples of the types of optional define() calls you can do:
https://github.com/umdjs/umd

I suggest this one for this case:

https://github.com/umdjs/umd/blob/master/amdWeb.js

if you think this library may be mixed an matched in an AMD
environment that expect Davis to also be a global, then:

https://github.com/umdjs/umd/blob/master/amdWebGlobal.js

> The main library by default requires jQuery, but can be used with
> other dom libraries, such as Zepto.  Do I need to declare jQuery as a
> dependency when calling define with my library?

Yes, use 'jquery' as the dependency name (in the above links in place
of the 'b' dependency). An developer using AMD can map 'jquery' to
point to the Zepto file, and use a tool to wrap Zepto in a define
call. In that way, Zepto can be used in place of the 'jquery'
dependency.

> Also Davis.js has a plugin system, with some default plugins provided,
> should these also be available as AMD modules, using the define
> method?  If so how do I include the main library as a dependency?

Yes, same approach as above, but I would use 'davis' as the dependency
name, and then optionally also passing in 'jquery' if the plugins need
jquery too. I would use 'davis' and not 'Davis', since 'davis' matches
the file name -- dependency IDs get mapped to file paths.

James


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.