systemjs/systemjs — pull request #63 by justinbmeyer (2014-04-12 00:50:23+00:00)
Title: Normalize hooks and shim -> meta

## Normalize Hook

A format can provide a normalize hook that adds custom behavior when the referrer is a module of that type. This looks like:

```js
System.format.special = {
normalize: function(name, referrer, referrerAddress, baseNormalize ) {
return moduleName
}
};
```

## Shim -> Meta

This replaces the System.shim config for the more adaptable `System.meta` config. `System.meta` will automatically add properties and values to a load record's metadata. The following assigns "arbitraryMetaProperty" and "exports" properties to the 'tests/global-multi' module and makes sure they are available after calling `System.locate`.

```js
System.meta = {
'tests/global-multi' : {
arbitraryMetaProperty: true,
exports: "jQuery"
}
};
var oldLocate = System.locate;
System.locate = function(load){
var res = oldLocate.apply(this, arguments);
if(load.name == "tests/global-multi") {
ok(load.metadata.arbitraryMetaProperty, "got arbitrary metadata");
}
return res;
};

System.formats.unshift("normalized");
System['import']('tests/global-multi').then(function(m) {
ok(m.jquery === 'here', 'exports works right');
start();
}, err);
```

To set the previously available shim properties of `deps` and `exports`, set those on `meta` like:

```
System.meta["moduleName"] = {
deps: ["depModule1", "depModule2"],
exports: "name.on.window"
}
```

To set the format to global, do that in meta like:

```
System.meta["moduleName"] = {
format: "global",
deps: ["depModule1", "depModule2"],
exports: "name.on.window"
}
```