{"action":"created","issue":{"url":"https://api.github.com/repos/ivogabe/small/issues/5","labels_url":"https://api.github.com/repos/ivogabe/small/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/ivogabe/small/issues/5/comments","events_url":"https://api.github.com/repos/ivogabe/small/issues/5/events","html_url":"https://github.com/ivogabe/small/issues/5","id":123707576,"number":5,"title":"Optional export for UMD standalone","user":{"login":"bisubus","id":2905949,"avatar_url":"https://avatars.githubusercontent.com/u/2905949?v=3","gravatar_id":"","url":"https://api.github.com/users/bisubus","html_url":"https://github.com/bisubus","followers_url":"https://api.github.com/users/bisubus/followers","following_url":"https://api.github.com/users/bisubus/following{/other_user}","gists_url":"https://api.github.com/users/bisubus/gists{/gist_id}","starred_url":"https://api.github.com/users/bisubus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bisubus/subscriptions","organizations_url":"https://api.github.com/users/bisubus/orgs","repos_url":"https://api.github.com/users/bisubus/repos","events_url":"https://api.github.com/users/bisubus/events{/privacy}","received_events_url":"https://api.github.com/users/bisubus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-23T18:52:57Z","updated_at":"2015-12-23T21:07:44Z","closed_at":null,"body":"This would be beneficial because it tends to pollute globals even when it is unncessary.\r\n\r\nThe possible case is Angular module, e.g.\r\n\r\n```\r\n(function(__root, __factory) {\r\n\tif (typeof define === \"function\" && define.amd) {\r\n\t\tdefine(\"module-name\", [\"angular\"], __factory);\r\n\t} else if (typeof exports === \"object\") {\r\n\t\tmodule.exports = __factory(require(\"angular\"));\r\n\t} else {\r\n\t\t__root[\"module-name\"] = __factory(angular);}\r\n})(this, (function(__small$_mod_0) {\r\n\r\nvar exports = {};\r\n...\r\nexports = \"moduleName\";\r\nreturn exports;\r\n}))\r\n```\r\nThe wide-spread convention for modular Angular workflow is\r\n\r\n```\r\nangular.module('appName', [require('module-name')]);\r\n// instead of\r\n// require('module-name');\r\n// angular.module('appName', ['moduleName']);\r\n```\r\n\r\nSo exported string is used only in the context of `require` or `import`, and `__root[\"module-name\"] = ` [could be safely omitted](https://github.com/ivogabe/small/blob/15f46c32fd0c4c3e7f13dbbb82c740dc54f12201/lib/project.ts#L296)  if `exportPackage.standalone === ''`.\r\n\r\nThe checks for `exportPackage.amd` and `exportPackage.commonjs` could be added for consistency as well, but I see no possible use for that.\r\n\r\nCan we do that?"},"comment":{"url":"https://api.github.com/repos/ivogabe/small/issues/comments/166990079","html_url":"https://github.com/ivogabe/small/issues/5#issuecomment-166990079","issue_url":"https://api.github.com/repos/ivogabe/small/issues/5","id":166990079,"user":{"login":"bisubus","id":2905949,"avatar_url":"https://avatars.githubusercontent.com/u/2905949?v=3","gravatar_id":"","url":"https://api.github.com/users/bisubus","html_url":"https://github.com/bisubus","followers_url":"https://api.github.com/users/bisubus/followers","following_url":"https://api.github.com/users/bisubus/following{/other_user}","gists_url":"https://api.github.com/users/bisubus/gists{/gist_id}","starred_url":"https://api.github.com/users/bisubus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bisubus/subscriptions","organizations_url":"https://api.github.com/users/bisubus/orgs","repos_url":"https://api.github.com/users/bisubus/repos","events_url":"https://api.github.com/users/bisubus/events{/privacy}","received_events_url":"https://api.github.com/users/bisubus/received_events","type":"User","site_admin":false},"created_at":"2015-12-23T21:07:44Z","updated_at":"2015-12-23T21:07:44Z","body":"It is a common case for any plugin/modular bundle, jQuery plugins are similar. They may have something to export, but in global scope they won't expose everything outside `jQuery`. There are a few ones that exploit UMD template like that.\r\n\r\nAngular 2 is totally different beast, I wouldn't worry about the future of 1.x  for the next 2-3 years. But yes, the things are going to change for 1.x, I guess that `angular.module` hardly requires any special treatment from module bundler, the same thing can be done now with ES7/TS decorators but in more conventional way. \r\n\r\nAnyway, customisable UMD template with logic (i.e. EJS) would be advantageous in this case imo."}}