In the AMD target the AMD module gets named, but in the UMD target its
is always anonymous, even if `library` is set in the config.
This patch names the AMD module if `library` is set.
See the discussion in the referenced issue to see the background for
this change.
If its a multi part library it uses the last key in the same was as it
does with the exports hash part of the UMD declaration. Is this the best
solution?
Resolves webpack/issues/989
Rationale: the missing semi-colon can cause bugs in some edge cases where webpack
is used to generate a library that will be concatenated in dependent project.
There isn't any mechanism in the amdjs spec to provide optional
dependancies (although a requirejs loader plugin could do that, it's not
standard). The best approach found was knockout's optional dependancy on
jquery, for which it doesn't use require, it only uses globals.
This solution will need to be improved for use of requirejs/amd in
commonjs environments, and could be toggled with a flag.