maqetta/maqetta — Issue #1174: Use AMD in user content, widget metadata
Author: peller
Created: 2011-11-07 04:07:40+00:00
State: open
Labels: Feature, Widget Libraries

AMD style require calls (instead of old dojo.require) is a prerequisite to the user turning on asynch loading in their application on deployment. It will also make it trivial for us to turn on asynch for preview.

See also #1093, which is about turning on the asynch loader for the visual editor itself, and may be a bit more complicated.

I think this should be as simple as fixing the metadata. Minimally, to be AMD-compliant, we need to use the new require API instead of dojo.require. It would be nice to bunch them all up into a single require call with an array, but individual calls will suffice. We could just do a global search/replace of dojo.require to require, but I'd like to consider a more robust definition in our widget metadata. We had discussed something like

In Button_oam.json:
{
"id": "http://dojotoolkit.org/dijit/form/Button",
"name": "dijit.form.Button",
"spec": "1.0",
"version": "1.0",
"require": [
{
"type": "javascript",
"src": "dojo/dojo.js",
"$library": "dojo"
},
{
"type": "css",
"src": "dojo/resources/dojo.css",
"$library": "dojo"
},
- {
- "type": "javascript",
- "$text": "dojo.require('dijit.form.Button');"
- }
+ {
+ "type": "amd",
+ "path": "dijit/form/Button"
+ }
],

@jhpedemonte need your review of metadata changes, and determination of whether we could give this a shot for M4, or push to M5

@childsb there's a reference to "dojo.require" in RebuildBase. If we can't get rid of this, we may need to check for both "dojo.require" and "require"