linkedin/dustjs — pull request #192 by jimmyhchan (2012-11-13 19:09:20+00:00)
Title: AMD friendly module pattern. Helper friendly and Cleanup compiler/parser

Making dust AMD friendly.
==========
Using the UMD pattern https://github.com/umdjs/umd/blob/master/returnExports.js

Biggest changes:
---------------
1. lib/dust.js
* remove the `getGlobal` method in favor of the passing the global this into the closure
* remove the export check and use the UMD pattern check (but I've kept the node server check in the module)
* set the `dust.helpers` object here (line 26)

1. lib/parser.js
* `Parser` doesn't actually depend on `dust` so don't pass it to parser. Instead, return/export the `parser` object. For the browser there is no change.

1. lib/compiler.js
* `Compiler` depends on the `parser` and not `dust`. Stop passing `dust` to the `compiler`. Instead of dumping everything into the `dust` object, return/export a `compiler` object that exposes specific methods (e.g. `compile`, `optimizers`). I had to copy escapeJS here since the compiler sneakily uses it...

Before
```
dust.compile
dust.filterNode
dust.optimizers
dust.pragmas
dust.compileNode
dust.nodes.*
dust.loadSource (in server.js)
```

After
```
dust.compile
dust.optimizers
dust.loadSource (in server.js)
```

1. MakeFile
* Increment to 1.1.2
* Reorder the files in full so that `parser` is included first since `compile` depends on it.