anodynos / uRequire

The Ultimate JavaScript Module Builder & Automagical Task Runner. Convert AMD & CommonJS/NodeJS modules to UMD, AMD, CommonJS or bundle them as `combined.js` (rjs & almond, AMDclean soon) & automagically run/test/watch them on nodejs, Web/AMD or Web/Script. Declarative & DRY config with inheritance. Manipulate & inject dependencies, module code, banners, version etc while building with a single line. Support two kinds of plugins, ResourceConverter (i.e file level) and AfterBuilder (i.e the whole bundle). Transparent support for Coffeescript, IcedCoffeescript, Coco, LiveScript – they’re just JavaScript :-)
http://anodynos.github.io/uRequire
MIT License
265 stars 20 forks source link

rootExports exports even if AMD is used #49

Closed xixixao closed 10 years ago

xixixao commented 10 years ago

The generated code, when using combined template, is simply

window.myAwesomeModuleName = __umodule__;

inside of a define. This will always register the global, even if I require my awesome module via RequireJS, which goes strictly against the documentation, which links the proper definition.

Otherwise, this project is awesome, thanks!

anodynos commented 10 years ago

Hi @xixixao and thanks for your comments.

This is a known behaviour, as mentioned in #36. Right now the behaviour is like in https://github.com/umdjs/umd/blob/master/amdWebGlobal.js#L22-L25, i.e to always export

window.myAwesomeModuleName = __umodule__;

even if AMD is present.

It is a trivial change in the templates to export it optionally when AMD loader is present, I am just a bit troubled on where to add the user option in the config - any suggestions ?

xixixao commented 10 years ago

I haven't used the config at all, so I can't help there. But I think the non-exporting should be default and the exporting an option.

anodynos commented 10 years ago

oh, your missing out :-) Yeah, probably its best that the default should be not to export