google/traceur-compiler — pull request #988 by guybedford (2014-04-28 05:03:32+00:00)
Title: Module naming and anonymous modules

This follows on from #974.

It allows the following compilation scenarios:

1. Don't write `__moduleName` with `--dir` option
```
traceur --dir es6Modules amdModules --modules=amd
```
Will now compile the directory of modules, without adding the `__moduleName` into all the modules. The same for CommonJS

2. Support AMD named defines - when the `ModuleName` transformer sets `this.moduleName` to a non-empty string, it will output a named AMD define of the form `define('moduleName', ...`.

3. With the previous it is now possible to compile a tree of ES6 into a tree of AMD named defines that will work directly as a RequireJS bundle:
```
traceur --out outFile.js inModule.js --modules=amd
```
This way you can immediately convert an application into a full RequireJS-style bundle in one go.

4. Allow a `moduleName` option for `traceur.compile` in the NodeJS API:
```
traceur.compile('function p() {}', { modules: 'amd', moduleName: 'myModule' });
```
will compile into a module with the `__moduleName` as set.

5. By default `traceur.compile` does not set the `__moduleName` at all assuming an anonymous module.

6. Similarly, by default `compile-to-amd` and `compile-to-commonjs` both assume anonymous by default.